28 March 2011

Testing Databases with JUnit and Hibernate

Bambitroll @ 13:51
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

2 Response to "Testing Databases with JUnit and Hibernate"

  1. Jens Schauder said...

    Thanks for linking to my blog.

    Why do you think using an ORM makes testing you persistence layer superfluous?

    kind regards
    Jens Schauder

  2. Bambitroll said...

    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!

Post a Comment