Ebean test

1. Add ebean-test as a test dependency

<dependency>
  <groupId>io.ebean</groupId>
  <artifactId>ebean-test</artifactId>
  <version>11.44.1</version>
  <scope>test</scope>
</dependency>

2. Add application-test.yaml

Add into src/test/resources a application-test.yaml configuration file that we use for testing.

ebean:
  test:
    platform: h2 #, h2, postgres, mysql, oracle, sqlserver, hana, clickhouse, sqlite
    ddlMode: dropCreate # none | dropCreate | create | migration | createOnly | migrationDropCreate
    dbName: my_app

We can modify this test configuration to control what DDL is executed (create-all.sql or migrations) and the database platform we want to test against (potentially using docker).

3. Add ~/.ebean/ignore-docker-shutdown

mkdir ~/.ebean
touch ~/.ebean/ignore-docker-shutdown

For running tests on CI servers we typically want to stop and remove the docker containers when the tests have completed. However, for local development we want to keep the docker containers running making it faster to run tests.

Adding a marker file ~/.ebean/ignore-docker-shutdown means the docker containers will stay running (which is good for local development).

ebean-test

ebean-test will take care of:

Edit Page