About DbUnit

DbUnit is a mature, proven JUnit extension, founded in 2002, targeted at database-driven projects that, among other things, puts the 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 data and causes subsequent tests to fail or exacerbate the damage.

dbUnit hooks into JUnit 5/6 (Jupiter) — JUnit 4 support was dropped in 3.0.0 — either by composing an IDatabaseTester into your test class (the preferred style) or by extending DBTestCase. Outside of tests, it is also a convenient utility for importing and exporting data — from code, via Ant Integration, or through the companion dbunit-maven-plugin.

What dbUnit Provides

  • Dataset formatsFlat XML, XML, CSV, JSON, YAML, and Excel, plus building datasets in code or reading them straight from a live query.
  • Database operationsINSERT, UPDATE, DELETE, DELETE_ALL, TRUNCATE_TABLE, REFRESH (upsert), and CLEAN_INSERT (truncate + insert), composable and transaction-wrappable.
  • Flexible assertionsValueComparer implementations go beyond strict equality: tolerance (numeric and timestamp), greater-than/less-than, null checks, string containment, and ignore-millis timestamp comparisons.
  • Broad database support — vendor-specific type and metadata handling for 10 databases: DB2, H2, HSQLDB, MariaDB, Mckoi, MSSQL, MySQL, Netezza, Oracle, and PostgreSQL; see Database-Specific Guides.

Where to Start

New to dbUnit? dbUnit in 5 Minutes is the fastest way to see it work. From there, Getting Started orients you toward what you need next, Test Integration covers the two ways to wire dbUnit into a test class, and Datasets covers the dataset file formats prep/expected data is written in.

Downloading dbUnit

Refer to Maven Repositories for obtaining releases and snapshots (pre-releases/work in progress).

Help Wanted

While dbUnit is a very mature product (its first commits date back to 2002), it has many needed improvements; not only new features and bug fixes, but documentation, refactoring, and modernization! We are a small team working on improvements and issues along the way, and need more help.

If you have interest in helping dbUnit, please start a discussion https://github.com/dbunit/dbunit-extension/discussions/categories/development, expressing interest and initial ideas. We will gladly help you as needed with your ideas and contributions and look to add you as a committer when ready.

News

Date News
2026-08-11 Release 3.5.0 available. It adds DbUnitExtension for native JUnit 5/6 lifecycle management, a new JSON dataset format and JSON ValueComparer, MariaDB and H2 2.x database support, expanded PostgreSQL json/jsonb and array type support, and an opt-in escape hatch for circular foreign keys, plus a ground-up documentation site overhaul and numerous other bug fixes. Refer to the changes report, the feature list, and the bug list for the release contents.
2026-07-28 Release 3.4.0 available. It adds an opt-in CachingConnectionProvider to cut per-test connection overhead, pins identifier matching to Locale.ENGLISH for Turkish-locale correctness, and fixes numerous timestamp, export-format, and resource-leak bugs. Refer to the changes report, the feature list, and the bug list for the release contents.
2026-07-22 Release 3.3.0 available. It is a large performance improving release, especially with high column count tables, having 22 improvements and 6 fixes. Refer to the changes report, the feature list, and the bug list for the release contents.
2026-06-04 Release 3.2.0 available. It adds DataSetBuilder for easing in-memory dataset creation, brings up full DB2 build/CI support, and fixes case-sensitive table lookups along with a long-standing ScrollableResultSetTable bug. Refer to the changes report, the feature list, and the bug list for the release contents.
2026-05-18 After 24 years at SourceForge, DbUnit moved to GitHub in May 2026. Source code, issues, and CI now all live at https://github.com/dbunit/dbunit-extension. Thank you, SourceForge, for 24 years of hosting.
2026-05-11 Release 3.1.0 available. It adds two ignore-millis ValueComparer implementations, moves release publishing to the new Central Portal with reproducible builds, and switches CI to GitHub Actions with auto-published snapshots. Refer to the changes report, the feature list, and the bug list for the release contents.
2025-01-25 Release 3.0.0 available. Its main change is JUnit 5 support (JUnit 4 dropped); it also adds TableDecoratorDataSet/GeneratedColumnFilterSupport for computed-column filtering and fixes Oracle/PostgreSQL driver-unwrapping bugs. Refer to the changes report, the feature list, and the bug list for the release contents.
2024-06-02 Release 2.8.0 available. It adds YamlDataSet, a new YAML-based dataset format. Refer to the changes report, the feature list, and the bug list for the release contents.
2022-02-12 Release 2.7.3 available. It lets an operation’s dataset be composed from multiple source files, adds new null-check ValueComparer implementations, and fixes a daylight-saving-time timestamp conversion bug. Refer to the changes report, the feature list, and the bug list for the release contents.
2021-07-25 Release 2.7.2 available. A small fix release: case-sensitive table name handling in DefaultPrepAndExpectedTestCase.cleanupData() and a connection-initialization bug. Refer to the changes report, the feature list, and the bug list for the release contents.
2021-07-22 Release 2.7.1 available. It upgrades Apache POI (Excel support) to 4.1.0, drops the commons-io and commons-collections dependencies for a lighter footprint, and fixes a Java 12 UUID-validation compatibility issue. Refer to the changes report, the feature list, and the bug list for the release contents.
2020-02-23 Release 2.7.0 available. It adds relative date/time syntax for dataset values and MSSQL datetimeoffset support, plus fixes a broken CachedDataSet and case-sensitivity handling in FilteredDataSet. Refer to the changes report, the feature list, and the bug list for the release contents.
2018-10-14 Release 2.6.0 available. It introduces the ValueComparer assertion strategy for pluggable per-column comparison, adds PostgreSQL OID data type support, and moves the build to Java 8. Refer to the changes report, the feature list, and the bug list for the release contents.
2017-08-20 Release 2.5.4 available. It adds [text]/[base64]/[file] cues for defining blobs directly in flat XML/CSV datasets, and fixes MSSQL IdentityInsertOperation erroneously always committing. Refer to the changes report, the feature list, and the bug list for the release contents.
2016-08-21 Release 2.5.3 available. A broad fix release: case-sensitive table name handling in DbUnitAssert/ReplacementDataSet, timezone-correct XlsTable reads, and support for 'true'/'false' string values in numeric fields. Refer to the changes report, the feature list, and the bug list for the release contents.
2016-04-08 Release 2.5.2 available. It adds multi-schema support for FlatXmlDataSet, stops inserting explicit nulls into NOT NULL columns that have a DEFAULT, and adds PostgreSQL CITEXT data type support. Refer to the changes report, the feature list, and the bug list for the release contents.
2015-04-11 Release 2.5.1 available. It adds the allowEmptyFields property to allow empty string fields without failing fast, fixes column aliases not being picked up, and upgrades Apache POI to 3.11. Refer to the changes report, the feature list, and the bug list for the release contents.
2014-04-24 Release 2.5.0 available. It adds PostgreSQL Geometry type support and UUID-to-binary dataset syntax, moves release publishing to Sonatype OSSRH, and fixes several CSV, MySQL, and Oracle metadata bugs. Refer to the changes report, the feature list, and the bug list for the release contents.
2012-09-30 Release 2.4.9 available. It adds support for MSSQL’s uniqueidentifier type, moves the build to JDK 6, and fixes a Timestamp sub-second regression introduced in 2.4.8. Refer to the changes report for the release contents.
2010-08-31 Release 2.4.8 available. It adds DefaultPrepAndExpectedTestCase for turn-key prep/verify test setups, adds timezone support to the timestamp data type, and adds a McKoi database driver. Refer to the changes report for the release contents.
2009-11-09 Release 2.4.7 available. It adds Oracle SDO_GEOMETRY datatype support and MSSQL NTEXT support, and fixes DatabaseSequenceFilter foreign-key table sorting on case-sensitive and cross-schema databases. Refer to the changes report for the release contents.
2009-10-09 We wish to welcome Jeff Jensen as a DbUnit developer, the project team is growing!
2009-09-24 Another member joined the DbUnit project developers group: welcome John Hurst!
2009-09-20 Your contributions has led us to cut a new release: DbUnit 2.4.6 is out. It adds support for the Netezza database, PostgreSQL interval/inet/enum types, and Oracle ROWID, plus fixes numbers over 19 digits failing to save in BIGINT columns. Here a detailed changes report.
2009-05-23 Another bugfixing release has been cut: DbUnit 2.4.5 is out. It adds PostgreSQL UUID data type support, Oracle BINARY_DOUBLE/BINARY_FLOAT support, and Excel output to the export task. Here a detailed changes report.
2009-02-24 We are proud to announce the 2.4.4 release has been cut. It adds DatabaseConnection methods for working with PreparedStatement`s, and fixes overridden `setUpDatabaseConfig() not being called and a DB2 regression from 2.4.0. Here a detailed changes report.
2009-01-20 Development continues to go on, fixes and a additions have been contributed and a new 2.4.3 release has been cut. It adds table-name pattern filtering, fixes a custom FailureHandler not being propagated to the data-comparison stage, and fixes incorrect identity-column detection for IDENTITY_INSERT. Here a detailed changes report.
2008-12-17 Some other fixes and a additions have been released in dbunit-2.4.2. It adds the StringIgnoreCase data type, fixes FEATURE_CASE_SENSITIVE_TABLE_NAMES reading the wrong DatabaseConfig property, and fixes inserts failing across multiple Oracle schemas. Here a detailed changes report.
2008-12-15 Another Open Source project named Jailer has added support for the DbUnit flat XML dataset file format. The integration provided by the Jailer project allows easy data sharing between the two projects. Well done Ralf!
2008-12-03 Previous version introduced a bug on Oracle-based tests, so we are proud to announce a quick new version (2.4.1) that fixes it. It also fixes inserting rows with a self-referencing foreign key, broken since 2.4.0. More information in the changes.
2008-11-27 DbUnit development is very active and is proud to announce the 2.4.0 release! It refactors the Assertion class, adds support for Oracle SQL*Loader dataset files, and fixes DatabaseSequenceFilter looping infinitely on a cyclic table dependency. Here are the changes.
2008-09-11 We all are so proud to announce the 2.3.0 release is finally out! A large release: it adds tolerated-delta floating-point comparisons and RowFilter support on ITable, optimizes ITableMetaData.getColumnIndex(), and improves Assertion failure reporting to list all mismatched columns. Have a look at the changes.
2008-06-08 Matthias Gommeringer joined the project team. Welcome Matthias!
2008-05-23 Well another bug fixing release is out: 2.2.3 fixes some annoying bugs! It fixes a memory leak and removes erroneous ERROR-level logging noise. Please see changes.
2008-05-05 Release 2.2.2 is out and fixes some annoying bugs! It fixes an IncompatibleClassChangeError regression from 2.2.1, restores JDK 1.4 compatibility, and fixes a CLOB datatype issue on Derby. Please see changes.
2008-03-19 Wiki is back…​. again!
2008-03-18 Release 2.2.1 is finally out!!! It adopts SLF4J for logging, adds an H2 data type factory, and fixes ReplacementTable being broken for multiple replacements. See changes.
2008-03-12 Sébastien Le Callonnec joined the project team.
2008-02-29 Release 2.2.1 is on it’s first steps. Snapshot release available on DbUnit Snapshots Maven Repo.
2007-12-01 Roberto Lo Giacco joined the project team.
2006-12-28 Version 2.2 finally released!!!. It adds table-dependency search support (org.dbunit.util.search/org.dbunit.database.search), a new HsqldbDataTypeFactory, and CSV datasets loadable from a URL. See changes.
2006-12-20 Wiki is back!.
2006-05-28 Build has been ported to Maven 2 and snapshots for the 2.2 release are available in the repository.
2006-02-04 Felipe Leme joined the DbUnit development team.
2005-08-19 Website Updated! Link to wiki has been removed. Many fixes in CVS for 2.2-dev, see changes.
2004-05-31 Version 2.1 released. Multiple bugfixes and enhancements. It adds the original CSV dataset implementation and the IColumnFilter interface for column filtering. See changes.
2004-04-28 DeveloperWorks article: Control your test-environment with DbUnit and Anthill.
2004-03-16 The DbUnit Wiki is now officially online. Please contribute to the SupportedRDBMS page.
2004-01-26 ONJava article: Effective Unit Testing with DbUnit.
2004-01-22 Version 2.0 released. A foundational release: introduces DatabaseConfig (replacing global system properties), DatabaseSequenceFilter for dependency-ordered operations, ReplacementDataSet, and XlsDataSet, and switches Assertion.assertEquals to typed value comparison. See changes.
2003-10-05 Version 1.5.6 released. It fixes NULL primitive values being read back as zero and Oracle CLOB values being read back as NULL. See changes.
2003-07-16 Federico Spinazzi joined the DbUnit development team.
2003-07-16 Version 1.5.5 released. It disables batched statements by default (many JDBC drivers have problems with it), speeds up DatabaseDataSet metadata caching, and fixes several XML-encoding and case-sensitive-table bugs. See changes.
2003-04-04 Version 1.5.1 released. It fixes DELETE not removing tables in reverse dependency order, and optimizes REFRESH and DTD export performance. See changes.
2003-03-01 Version 1.5 released. It adds case-insensitive table/column matching, the escapePattern property for escaping table names, and the SortedTable/SortedDataSet decorators. See changes.
2002-11-07 Eric Pugh joined the DbUnit development team.
2002-07-17 The java API documentation is now available online.
2002-07-17 Version 1.4 released. It adds DbUnitTask, Ant integration, and BLOB/CLOB data type support. See changes.
2002-05-10 Timothy Ruppert and Ben Cox joined the DbUnit development team.
2002-04-04 Version 1.3 released. It adds binary data type support (BINARY/VARBINARY/LONGVARBINARY, base64-encoded in XML) and introduces Assertion.assertEquals as the successor to DataSetUtils.assertEquals. See changes.
2002-04-04 New website design and logo done by Silphid Creations.
2002-03-19 Version 1.2.4 released. It adds support for multiple schemas per connection and fixes DATE/TIME/TIMESTAMP handling. See changes.
2002-03-15 Version 1.2 released. It adds the flat XML dataset format (FlatXmlDataSet) and database data verification. See changes.
2002-03-10 Version 1.1 released. It adds the IDatabaseConnection interface and DatabaseDataSourceConnection. See changes.
2002-02-27 Version 1.0 released. This is the first public release.