Add Testcontainers + @DataJpaTest against real PostgreSQL 16 #119
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
The backend test suite has zero integration tests that run against a real PostgreSQL database. The
pom.xmlincludes H2 in test scope, and all controller tests mock the service layer. This means:Why This Matters
H2 is a different database. It silently accepts SQL that PostgreSQL would reject. We have caught this pattern in other projects — mocked/in-memory tests pass, production migration fails. The cost of that discovery is far higher than the cost of fixing this now.
What Needs To Be Done
pom.xml:@DataJpaTesttest class with a sharedPostgreSQLContainervia@DynamicPropertySource@DataJpaTesttests for at leastDocumentRepositoryandPersonRepositorycovering:@SpringBootTestsmoke test that starts the full application context against the containerAcceptance Criteria
DocumentRepositoryandPersonRepositoryhave@DataJpaTestcoveragepom.xmlArchitect review (@mkeller): ✅ Most important ticket in this batch — do this first.
H2 in test scope is a genuine liability. Flyway migrations never running in CI will eventually cause a production incident. The concern here is well-founded.
One implementation note: the ticket shows
@DynamicPropertySourceto wire the container, which is the Spring Boot 3.0 pattern. This project runs Boot 4.0 — use@ServiceConnectioninstead, it's less ceremony and more idiomatic:Also: sequence this before #120 (JaCoCo coverage gate). There is no point enforcing an 80% gate against a mock-heavy test suite. Get real tests in place first, measure the actual baseline, then gate.