Fork me on GitHub

Embedded PostgreSQL for Java

Start a PostgreSQL server for unit testing or local development.

This library controls PostgreSQL server instances and gives easy access to one or more databases on the database server. Using pg-embedded makes unit and integration tests simple and allows easy development without having to install local binaries.

How it works

The library spins up one or more PostgreSQL servers up and controls their lifecycle through EmbeddedPostgres instances. When an instance is closed, the database server is shut down.

EmbeddedPostgres class instances manage a PostgreSQL server. Each server is independent, multiple instances will manage multiple, independent servers. This allows testing of more complex systems that may use multiple databases.

DatabaseManager provides an API to manage one or more database instances on a PostgreSQL server. Each DatabaseManager manages a PostgreSQL server.

pg-embedded supports the JUnit5 test framework directly through EmbeddedPgExtension.

How to use it

Testing with pg-embedded