File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Testing and the fly likes How to test a javabean Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » Testing
Bookmark "How to test a javabean" Watch "How to test a javabean" New topic

How to test a javabean

patt rich

Joined: Apr 07, 2008
Posts: 21
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?

Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 33132

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.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
I agree. Here's the link:
subject: How to test a javabean
It's not a secret anymore!