Should simple JavaBeans that have only simple getters and setters be unit tested??
What about Beans with some logic in getters and setters?
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.
You should not write tests which:
The same applies for .NET objects which only have properties (sometimes called ‘Info’ objects).
In an ideal world you would have 100% test coverage, but in practice this is not going to happen. So spend the client’s money where it will add the most benefit i.e. writing tests for classes with complex state and behaviour.
If your JavaBean becomes more interesting you can of course add a test case later. One of the common problems associated with Unit Testing / TDD is the mistaken belief that everything has to be perfect first time.