Welcome to the DbUnit Wiki!

DbUnit is a JUnit extension (also usable with Ant) targeted for database-driven projects that, among other things, puts your database into a known state between test runs. This is an excellent way to avoid the myriad of problems that can occur when one test case corrupts the database and causes subsequent tests to fail or exacerbate the damage.

Note on SLF4j

As of version 2.2.1, DbUnit uses the SLF4J library for logging purposes (See dependencies). This allows DbUnit users to use their favourite logging library (log4j, JCL, etc.).

When using DbUnit, you must therefore download SLF4J and include slf4j-api-*.jar and the implementation library of your choice in the classpath: for example, slf4j-log4j12-*.jar for Log4J, or slf4j-jcl-*.jar for commons-logging. However, make sure there is only one implementation library in your classpath, as failing to do so might cause some issues. Please see the SLF4J website for more details.

DbUnit topics

Database Testing Related topics

  • NDbUnit - A .NET database unit testing framework
  • MockObjects
  • MockTestingVsRealDatabaseTesting?
  • Data Storm A free embedable database viewer that enables you to view data that will be rolled back at the end of the test. Very good for fixing failing tests.
  • Jailer Database Subsetting Tool, extracts data from productive databases and generates flat XML dataset files.

dbUnit 3.0 Planning

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License