Should simple JavaBeans that have only simple getters and setters be unit tested??
What about Beans with some logic in getters and setters?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With