Is there a Java unit-test framework that auto-tests getters and setters?

Posted by Michael Easter on Stack Overflow See other posts from Stack Overflow or by Michael Easter
Published on 2008-09-20T16:43:11Z Indexed on 2010/06/01 9:13 UTC
Read the original article Hit count: 202

Filed under:
|
|

There is a well-known debate in Java (and other communities, I'm sure) whether or not trivial getter/setter methods should be tested. Usually, this is with respect to code coverage. Let's agree that this is an open debate, and not try to answer it here.

There have been several blog posts on using Java reflection to auto-test such methods.

Does any framework (e.g. jUnit) provide such a feature? e.g. An annotation that says "this test T should auto-test all the getters/setters on class C, because I assert that they are standard".

It seems to me that it would add value, and if it were configurable, the 'debate' would be left as an option to the user.

© Stack Overflow or respective owner

Related posts about java

Related posts about unit-testing