Skip to content
Tool Review · Database Testing & Test Data

DbUnit

DbUnit is a free, LGPL-licensed Java library for JUnit that loads databases into a known state from datasets before each test and compares table contents with expected data, with 3.x releases in 2025 and 2026.

Free Research-based review
Last verified November 2026. Version checked: 3.5.2 (7 September 2026). Features and pricing for commercial products change; check the vendor site for the latest details.
Product status: DbUnit is actively maintained again: 3.0.0 (January 2025) moved it to JUnit 5 and dropped JUnit 4 support, and releases 3.3.0 to 3.5.2 followed between July and September 2026. The older dbunit.org site still shows 2.4.9 (2012) as the latest release and is out of date.
Vendor
DbUnit open source project
Price
Free
Platforms
Java 8+ (any OS with a JVM)
Licence
GNU LGPL 2.1
Product type
Java library, open source (LGPL 2.1)
Works with
PostgreSQLMySQLMariaDBSQL ServerOracleDb2H2HSQLDBAny JDBC database

At a glance

Supported databasesAny JDBC database; specific guides for ten engines
Data generationNo generators: loads fixture datasets you write or export
MaskingNot documented
Referential integrityDataset order and operations are your responsibility
CI/CD integrationRuns inside JUnit, Maven or Ant builds
Test automationSetup and expected-state assertions for JUnit 5/6 tests
Data volume or subsettingSmall fixture datasets; export from live data is possible
DeploymentJava library (Java 8+ core API)
LicensingFree, GNU LGPL 2.1
Short answer

DbUnit suits Java teams that write JUnit integration tests against a real database and want each test to start from a defined data set and assert on table contents afterwards. It is free and works with any JDBC database. It does not start databases for you, so it is often paired with Testcontainers, and the 3.x line requires JUnit 5 or 6 rather than JUnit 4.

How we know: This profile is research-based: features, release history and licensing were checked on 7 November 2026 against the DbUnit documentation site at dbunit.github.io, its changes report, and the GitHub repository. We have not run DbUnit.

Overview

DbUnit is a long-running open source Java project that extends JUnit for database-driven tests. Before a test, it applies a dataset to the database with an operation such as CLEAN_INSERT (delete then insert), REFRESH or TRUNCATE_TABLE; after the test, it can read the actual tables and compare them with an expected dataset. It can also export data from a live database into dataset files, which is a common way to create the first fixtures.

Development moved to GitHub (repository dbunit/dbunit-extension, documentation at dbunit.github.io). Version 3.0.0 (25 January 2025) added JUnit 5 support and dropped JUnit 4; 3.5.0 (August 2026) added a DbUnitExtension for JUnit 5 and 6, a JSON dataset format and MariaDB and H2 2.x support. The core API still targets Java 8 bytecode, while building the project requires JDK 17.

Key features

  • Dataset formats: flat XML, XML, CSV, JSON, YAML and Excel, plus datasets built in code or from a live query
  • Database operations INSERT, UPDATE, DELETE, DELETE_ALL, TRUNCATE_TABLE, REFRESH and CLEAN_INSERT
  • Assertions that compare actual table or query contents with expected datasets
  • DbUnitExtension for JUnit 5 and 6 (Jupiter) lifecycle management, added in 3.5.0
  • Export of existing database data into dataset files for fixtures
  • Database-specific guides for ten engines, including PostgreSQL, MySQL, MariaDB, SQL Server, Oracle, Db2, H2 and HSQLDB
  • Ant task and a companion dbunit-maven-plugin

Integrations and ecosystem

JUnit 5 and 6 (Jupiter)Spring TestContext (annotation support in 3.6.0 snapshots)Maven (dbunit-maven-plugin)Apache AntJDBC driversTestcontainers

Pros and cons

Pros

  • Free and open source with frequent 2026 releases
  • Works with any JDBC database
  • Many dataset formats, including JSON, YAML, CSV and Excel
  • Expected-dataset assertions check the whole table state, not only return values

Cons

  • Java only
  • JUnit 4 support was dropped in 3.0.0, so JUnit 4 suites must stay on 2.x or migrate
  • Does not create or start databases; you supply the database (for example with Testcontainers)
  • The old dbunit.org site is stale, which can mislead when checking versions

Pricing

DbUnit is free, open source software under the GNU Lesser General Public License 2.1, published to Maven Central as org.dbunit:dbunit. There is no paid edition.

Pricing checked on the vendor's official page on 7 November 2026. Prices change; confirm before buying.

Who it is best for

Java teams writing JUnit 5 or 6 integration tests that need a known database state before each test and table-level assertions afterwards.

Typical use cases

  • Resetting tables to a fixture before each repository or DAO test
  • Verifying that a service call left the expected rows in several tables
  • Exporting a small slice of a shared test database into versioned fixture files
  • Running the same data-driven tests against H2 locally and PostgreSQL in CI

Who should look elsewhere

  • Teams testing stored procedures inside SQL Server or PostgreSQL in SQL itself: see tSQLt or pgTAP.
  • Teams that need large volumes of realistic synthetic data rather than hand-written fixtures.

Verdict

Our take

DbUnit is a mature, free option for putting JDBC databases into a known state and asserting on their contents in Java tests, and its 2025 and 2026 releases have modernised it for JUnit 5 and 6. It covers fixtures and assertions only, so plan to combine it with a way to provision the database, such as Testcontainers.

Frequently asked questions

Is DbUnit still maintained?

Yes. Releases 3.3.0 to 3.5.2 shipped between July and September 2026, with development on GitHub. The dbunit.org site still shows 2.4.9 from 2012 and is out of date.

Does DbUnit support JUnit 5?

Yes. Version 3.0.0 added JUnit 5 support and dropped JUnit 4, and 3.5.0 added a DbUnitExtension for JUnit 5 and 6.

Is DbUnit free for commercial use?

DbUnit is licensed under the GNU LGPL 2.1, which allows use as a library in commercial projects; read the licence for the conditions on modifying and redistributing DbUnit itself.

Which Java version does DbUnit need?

The 3.5.0 notes say JDK 8 is enough for the core API and the jar targets Java 8 bytecode, while building and running DbUnit's own tests requires JDK 17 or newer.

Sources

Checked November 2026.

Listed in: Database Testing & Test Data.

How we research reviews and what star ratings mean: our editorial method.

Compare your options

Browse the full tools directory or see the head to head comparisons.