Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to test a javabean

 
patt rich
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a javabean class. I should add Junit test class for that. I am wondering how to add test cases for getter setter methods. Evenif I add, will that be a proper testing of Java? Or are we just testing the java compiler by doing this?

Thanks
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34095
337
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Patt,
In general, testing getters and setters directly doesn't add much value. However, a good suite of tests will cover those methods indirectly by testing the classes that call those getters and setters.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic