Link Details

Link 73838 thumbnail
User 172008 avatar

By dwdyer
via blog.uncommons.org
Published: Apr 02 2008 / 15:48

A frequent topic of Java-related blogs is whether it is worthwhile to write unit tests for simple getters and setters. What bothers me most is the motivation for wanting to test getters and setters in the first place. It seems that many of those advocating unit testing simple getters and setters are driven by a desire to improve their coverage scores with the actual utility of the tests a secondary concern.
  • 9
  • 2
  • 1404
  • 443

Comments

Add your comment
User 236137 avatar

dzonelurker replied ago:

0 votes Vote down Vote up Reply

Ever heard of Java Beans? "Its properties must be accessible using get, set and other methods (so called accessor methods) following a standard naming convention. This allows easy automated inspection and updating of bean state by frameworks" http://en.wikipedia.org/wiki/JavaBeans
A lot of Java frameworks are built around JavaBeans. The question of "too many getters and setters" and "avoiding testing difficult code" is moot.

Add your comment


Html tags not supported. Reply is editable for 5 minutes. Use [code lang="java|ruby|sql|css|xml"][/code] to post code snippets.

Voters For This Link (9)



Voters Against This Link (2)