The first final release of the Embedded DB JUnit Rule has been released. It has proven to be a lightweigth tool for testing database logic by using an embedded H2 in-memory database.


Add dependency

Include the following in your pom:


If you are using SBT, add the following:

libraryDependencies += "org.zapodot" % "embedded-db-junit" % "1.0.0" % "test"

Add the EmbeddedDatabaseRule to the test class:

public EmbeddedDatabaseRule dbRule = EmbeddedDatabaseRule
                                        .withInitialSql("CREATE TABLE Customer(id INTEGER PRIMARY KEY, name VARCHAR(512)); "
                                                        + "INSERT INTO CUSTOMER(id, name) VALUES (1, 'John Doe')")
public void testUsingConnectionUrl() throws Exception {

    try(final Connection connection = DriverManager.getConnection(embeddedDatabaseRule.getConnectionJdbcUrl())) {
        try(final Statement statement = connection.createStatement();
            final ResultSet resultSet = statement.executeQuery("SELECT * from CUSTOMER")
        ) {


Support for testing Liquibase migrations

Version 1.0 includes support for creating database structures using existing Liquibase changelogs. To set up in your test, use the LiquibaseInitializer.

public EmbeddedDatabaseRule embeddedDatabaseRule = EmbeddedDatabaseRule


Do you have any questions or suggestions, please report an issue :-).