tags:

views:

95

answers:

2

I don't know if I should test my @Entity-annotated Pojos. After all, there are mainly just generated getters/setters. Should I test them?

When it comes to testing DAOs I'm using all those entities - so they are already propely tested, I guess?

Thanks for your thoughts.

Matt

+3  A: 

Can your code contain any bugs? If not, what's the point in testing it? In fact, trying to test it would just introduce new bugs (because your tests could be wrong).

So the conclusion is: You should not test getters and setters without code (i.e. those which just assign or read a field without any additional code).

The exception is: When you manually write those getters/setters because you could have made a type. But even then, some code will use these and there should be a test for that code which in turn tests whether the getters/setters behave correctly.

Aaron Digulla
Thanks for your answer, Aaron!
Matt
+1  A: 

The only reason I could think of the write tests would be to test the @Entity annotation itself. Testing the storage and retrieval of values seems like one is doubting a fundamental ability of our programming environment :)

LenW