Summary

Unitils is an open source library aimed at making unit testing easy and maintainable. Unitils builds further on existing libraries like dbunit and integrates with JUnit and TestNG.

Unitils provides general asserion utilities, support for database testing, support for testing with mock objects and offers integration with Spring, Hibernate and the Java Persistence API (JPA). It has been designed to offer these services to unit tests in a very configurable and loosely coupled way. As a result, services can be added and extended very easily.

Unitils offers following features:

  • General testing utilities
    • Equality assertion through reflection, with different options like ignoring Java default/null values and ignoring order of collections
  • Mock objects support
    • Dynamically define stub behavior of and verify invocations on mock object using a simple syntax.
    • Optimal feedback including a simple and extended execution scenario report and suggested assert statements.
    • Use argument matchers for relaxing method parameter constraints and mix them with concrete objects. Use null when the actual argument value is not important.
    • Use dummy objects when stub data objects without any required behavior are needed.
  • Persistence layer testing support
    • Automatic maintenance of databases, with support for incremental, repeatable and post processing scripts
    • Automatically disable constraints and set sequences to a minimum value
      • Support for Oracle, Hsqldb, MySql, DB2, Postgresql, MsSql and Derby
    • Simplify test database connection setup
    • Simple insertion of test data with DBUnit
      • Run tests in a transaction
      • JPA entity manager creation and injection for hibernate, toplink and openjpa
    • Hibernate SessionFactory creation and session management
    • Automatically test the mapping of JPA entities / hibernate mapped objects with the database
  • EasyMock integration support
    • Simplify EasyMock mock object creation
    • Simplify mock object injection
    • EasyMock argument matching using reflection equality
  • Spring integration
    • ApplicationContext configuration and easy injection of spring managed beans into a unit test
    • Support for using a Spring-configured Hibernate SessionFactory in unit tests.

Documentation

  • An overview of the features and how to configure and use them is available as a tutorial.
  • To get started with quickly, there is also a cookbook available, containing step-by-step instructions on how to configure your tests.

News

2009-06-02 - Release of Unitils 2.3

This minor release contains a new implementation of the expected dataset behavior, new argument matchers for the mock mock framework and some other small features. It also contains important bug fixes for the mock framework. Check the release notes for more details.

2008-12-19 - Release of Unitils 2.1 and 2.2

Unitils 2.1 and 2.2 only contain bugfixes. The release of Unitils 2.1 was immediately followed by a release of version 2.2, because we found an important bug in the 2.1 release, and we had to bring out a new release since version 2.1 was already published in maven. Check the release notes for more details.

2008-10-28 - Release of Unitils 2.0

We're proud to announce the new major version! In this version adds a new module has been added for writing tests with mock objects. The DbMaintainer has been extended with a number of new features and several bugs were fixed. Take a look at the migration page to know what must be done to migrate to version 2.0.

2008-06-25 - Release of Unitils 1.1

This release includes support for MsSql, some bug fixes and a few small improvements.