AssertJ-DB assertions

AssertJ-DB provides assertions to test data in a database. It requires Java 7 or later and can be used with either JUnit or TestNG.

If you need additional assertions, please create a ticket in the AssertJ-DB issue tracker.

AssertJ-DB is hosted on github :

Big thanks to  Joel Costigliola  for his welcome, for his help and for having accepted to associate this project with a great project like AssertJ.

Régis Pouiller (AssertJ-DB creator)

Suppose that the database contains this table :

1 'Hewson' 'Paul David' 'Bono' 05-10-60 1.75
2 'Evans' 'David Howell' 'The Edge' 08-08-61 1.77
3 'Clayton' 'Adam'   03-13-60 1.78
4 'Mullen' 'Larry'   10-31-61 1.70

To quickly start using DataBase assertions, follow the steps below.


If you use another dependency tool, please check this page to find the relevant assertj-db dependency declaration for your tool.

... and use your preferred IDE code completion after assertThat.

Example from :

import static org.assertj.db.api.Assertions.assertThat;

import org.assertj.db.type.DateValue;
import org.assertj.db.type.Table;

Table table = new Table(dataSource, "members");

// Check column "name" values

// Check row at index 1 (the second row) values
                 .value().isEqualTo("David Howell")
                 .value().isEqualTo("The Edge")
                 .value().isEqualTo(DateValue.of(1961, 8, 8))

In this simple example you can see many concepts of AssertJ-DB (the concepts are simple but I advice you to take the time to get to know them well) :

  • the elements :
    • Table which represents a table in the database
    • Column which represents a column of the table
    • Row which represents a row of the table
    • Value which represents a value in a column or in a row
  • the navigation :
    • The first check, navigates from the table to the column called "name" (column("name") moves the assertion to the column), from this column to the first value (the first call of value() moves to the first value) and after that to each value (each call of value() moves to the next value of the column).
    • The second check, navigates from the table to the row with index 1 (row(1) moves the assertion to the row), from this row to the first value and after that to each value (value() calls have similar behavior for rows and columns).
  • DateValue : AssertJ-DB works with Java7. So AssertJ-DB provides way to easily compare values with date, time and date/time.

Release date : 2016-04-23 (dependency declaration)

Javadoc : for versions 1.1.x

  • issue #37 : assertj-db 1.1.0 does not work with java 7

Latest javadoc release : AssertJ DB javadoc.

See some of AssertJ-DB noteworthy features to get the maximum of it !

You can learn more by looking at the AssertJ-DB javadoc.

Another way is to take a look at the assertj-db-examples tests. They show what is possible with AssertJ DB Assertions with running code. You can clone the repository and run its tests !

If you have any questions, please use the AssertJ google group.

AssertJ-DB is hosted on github :

Please report bugs or missing features in the AssertJ-DB issue tracker.

Thanks for your interest ! Please check our contributor's guidelines.