junit5-testcontainers-patterns

Installation
SKILL.md

JUnit 5 + Testcontainers patterns

Choose the smallest scope that covers the AC

AC type Use
Pure logic (calculator, validator, mapper) Plain JUnit 5, no Spring
Controller validation, status codes, JSON shape @WebMvcTest
JPA query / mapping @DataJpaTest + Testcontainers (@ServiceConnection)
End-to-end through HTTP, with DB / external @SpringBootTest(webEnvironment = RANDOM_PORT) + Testcontainers
Cache, security filter chain, bean wiring targeted slice (e.g. @WebMvcTest + @Import)

@SpringBootTest is a last resort. If a slice test can cover it, use the slice.

Naming + traceability

  • Every @Test and @ParameterizedTest method MUST carry @DisplayName. No exceptions — write the display name before the test body so articulating it forces clarity about what the test verifies. (Project rule: feedback_displayname_on_every_test.md.)
  • The full annotation block on every test method is all three lines, in this order:
Installs
1
GitHub Stars
39
First Seen
Jun 21, 2026
junit5-testcontainers-patterns — loiane/specs-driven-development-spring-angular