Show HN: Fast Isolated Postgres DB for Spring Boot Integration Tests

1 misirio 0 9/11/2025, 6:17:47 PM github.com ↗
I build a small Spring Boot library that makes Postgres-backed integration tests both fast and fully isolated.

How it works:

At test-suite start-up it creates a single PostgreSQL template database.

For every JUnit test it runs CREATE DATABASE … TEMPLATE … to clone that template - about 50 ms per sandbox.

It plugs right into Spring Boot, Testcontainers, Flyway, and Liquibase.

If you use text fixtures you can mess with it freely, and never worry about affecting other tests.

I introduced this approach after hitting serious test-isolation problems on a large enterprise project. The approach worked greatly and the integration tests grow to past 4 000 tests without any slowdown or cleanup scripts.

I added an example project setup including test fixtures here: https://github.com/misirio/dbsandboxer/tree/main/examples/sp...

I would love to hear your feedback and how you solve this problem in your projects.

Comments (0)

No comments yet