Is there a framework or library available that, when given a JavaBean, will “put it through its paces,” i.e., test all the getters and setters, validate that a property matches the getters and setters, etc.?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Personally, I don’t think that’s the hardest part of testing. It’d be possible to do via reflection, but that’s not what makes testing worthwhile.
The hard part is figuring out all the possible inputs, for “happy path” and erroneous situations, making sure that exceptions are thrown when they should be, etc.
Your Java Bean should be implementing equals and hashCode. I’d worry more about tests to check the equals contract: null equals, reflexive, symmetric, transitive, and not equals. Those aren’t trivial.
Getters and setters are the least of your problems. When people talk about code coverage standards of 70% or better they often say that getters and setters can be left out.