Posts Tagged Integration testing

Mar 11 2013

Fast and easy integration tests for your Hibernate data layer with HSQLDB and DBUnit

Integration testing with Hibernate

I guess there is no need to introduce Hibernate (, probably the most populare Java ORM framework. One main point of an ORM is that it decouples your data layer logic from the underlying RDBMS, making it relatively easy to switch among different solutions. Moreover, the early adoption of a package like Hibernate helps maintaining an Agile approach over your project, since schema changes are smooth to handle and your schema can be versioned, tagged and so on within the same versioning system used for your code.

A potential big pain of developing your application data layer may arise when it comes to integration testing. Singularly, your classes (and DAO) have been tested in full isolation, but there comes a time where you have to make sure your interaction with the real RDBMS works as expected; testing this part may result relatively slow and additional issues should be taken into consideration.
Testing over a real RDBMS means that all your data manipulations are persisted. As this is a trivial observation, it means anyway that without some proper treatments, running twice a test that modifies your data store (i.e. producing some insertions\updates\deletes) will likely lead to different results.


Globetrotter Software Engineer. I try to conjugate where the ambitions lead me with an environment that makes me feel happy. I love sun and sea. My mind is always spinning, for good and for bad. I enjoy traveling and experiencing new places by being constantly surprised by things I would have never even conceived.