I work on a project where we have to create unit tests for all of our simple beans (POJOs). Is there any point to creating a unit test for POJOs if all they consist of is gette
IMHO POJOs are automatically tested when logic for any functionality is tested, e.g. For testing any functions, we may need to inject/mock certain values, POJOs, and getter/setter for POJOs are indirectly tested.
However for the specific use-case to eliminate POJOs for unit-testing, it can be achieved following 2 ways:
USE LIBRARY: use existing libraries that help test POJOs. One such library I came across is meanbean.
Ref: http://meanbean.sourceforge.net/
Maven: http://mvnrepository.com/artifact/org.meanbean/meanbean (current version: 2.0.3)
IGNORE POJOs: Sonar can be configured to exclude POJOs or specific packages to be excluded from unit-test coverage reports. Few examples below:
**/domain/**/*,
**/pojos/*