intermediateTesting the Persistence Layer — @DataJpaTest & Testcontainers
What does Testcontainers actually do differently from an embedded database like H2?
It spins up a real, ephemeral Docker container running the actual production database engine (real PostgreSQL, for instance) for the duration of the test run, rather than an in-memory approximation — tests run against genuinely the same engine as production, catching database-specific behavior an embedded database can't.
This is a Pro chapter
Sign in, then upgrade to Pro or Power to unlock this and the full Spring Ecosystem Mastery library.
What does Testcontainers actually do differently from an embedded database like H2?