Here a 3 part blog post showing how to use JUnit and Hibernate (and Hypersonic) to test your database layer. Often using an ORM makes this superfluous but in some cases it can be an interesting to do.
Part 1
Part 2
Part 3
28 March 2011
Subscribe to:
Post Comments (Atom)
Thanks for linking to my blog.
Why do you think using an ORM makes testing you persistence layer superfluous?
kind regards
Jens Schauder
Jens, what I am saying is that it feels that unit testing your database layer when it is written via JPA is a bit like testing that your ORM is working correctly.
In the test called "returnsHerosWithMatchingType()", you create entities and then you check that they are correctly created. This is fair enough but I feel that it is the job of the ORM to ensure that.
On the other hand, I found error in my code via this kind of testing (I was trying to use an annotation in the wrong way) so it can be useful!