Documentation / Testing
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
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 will take care of:
- DDL generation and execution modes
- Docker test container setup and execution based on the database platform
- Current user and tenant provider if not already specified (to ease testing with @Who properties etc)