Documentation / Setup / Testing
application-test.properties / application-test.yaml
For new applications, prefer explicit test startup using Database.builder()
and regular test configuration files such as
src/test/resources/application-test.properties or
src/test/resources/application-test.yaml.
Keep the test datasource configuration in those files and create the
Database explicitly in your test wiring.
Database database = Database.builder()
.name("db")
.loadFromProperties()
.defaultDatabase(true)
.build();
ebean-test
For integration tests, prefer docs / testing and
ebean-test. It provides Docker-backed databases, test-specific platform
configuration, and a much better path than older implicit bootstrap approaches.
Mocking
If your application code depends on injected Database instances then testing is
straightforward: replace the injected dependency with a test double or alternative test wiring.
Older applications that rely on Model, active-record style APIs, or the global registry may still
need to register a default database for compatibility. For new code, prefer explicit
Database injection over singleton-based access.