Integration and end-to-end testing with TestContainers and JUnit 5
summary
TestContainers runs real Postgres and Redis inside throwaway Docker containers, integrates with JUnit 5, and binds container lifecycles to tests so ports are randomized and containers are cleaned by a Ryuk cleanup container. Demo code shows a Spring Boot user service with Postgres container model and an item service using Redis; a five-container end-to-end setup (including Eureka) boots in about a minute, passes assertions that data flows between services, then tears down with no leftover containers.
AI-written summary · about
chapters (23)
- 0:00Intro
- 0:39Why integration testing?
- 1:47Basic integration test
- 2:07Integration testing evolution
- 3:15Docker advantages
- 4:20Start Docker containers for integration test
- 5:55Maven plugins
- 6:30Docker Compose
- 7:18Docker API
- 9:58Docker environment discovery
- 10:16Host port randomization
- 11:00Containers cleanup
- 11:56Waiting strategies
- 12:51Host port waiting strategy
- 22:59Demo recap
- 24:37JUnit 5 extensions
- 40:38Testing environment cluster
- 41:19Test cluster for automated E2E tests
- 43:16On-demand cluster for E2E tests
- 45:45Non-Kubernetes for E2E tests
- 48:03Docker network aliases
- 48:46Spring Cloud Eureka service names
- 58:29Takeaways
related talks
24mIntegration Testing Made Easy: Leveraging Testcontainers and
28mPostmortem: TDD with TestContainers
50mMastering Integration Tests with Testcontainers.
46mRemoving complexity from integration tests using Testcontainers!
48mTestcontainers and Spring Boot from integration tests to local development!
32mMock my infrastructure! Using Testcontainers for better integration tests.
26mRemoving Complexity from Integration Tests Using Testcontainers
43mRemoving complexity from integration tests using Testcontainers!
