Unitils: a better Gienah?

On my current project, I am using Gienah as a way to integrate JUnit tests with Spring. I am rather pleased with the result, keeping my unit tests quite clean.

I just heard today about Unitils, a more ambitious tool. In addition to Spring, it supports TestNG, DbUnit, EasyMock, and Hibernate (ie. almost all that we are using here!). It also provides a number of additional services, such as helper asserts.

Especially intriguing are two things:

  • they recommend temporarily removing some db constraints, and provide help to do so (“To keep database tests maintainable, test data files have to be as small as possible. (Referential) constraints however don’t help you to achieve this. We advise to disable all foreign key and not null constraints. Doing so makes it possible to specify only the data that matters for your test.“)
  • they handle database versions is a way very similar to Ruby on Rails (“The database maintainer monitors a directory on the filesystem that contains DDL scripts for creating the structure of the database. The name of these scripts should comply with following naming convention: <version>_<some name>.sql. For example: 001_create_person_table.sql, 002_create_car_table.sql“)

See here for details.

About Eric Lefevre-Ardant

Independent technical consultant.
This entry was posted in hibernate, java, spring, test. Bookmark the permalink.