Testcontainers best practices.
summary
Testcontainers runs real services in on‑demand Docker containers so tests use the same versions as production; the talk shows Java code that starts PostgreSQL and Redis containers, uses Testcontainers modules (PostgreSQLModule, KafkaModule) instead of GenericContainer, and measures speed improvements (examples: sleeps drop tests from ~8s to ~2s when replaced by use wait strategies). Advice includes avoid static host and port, don't hardcode container names, pin explicit image versions (not latest), and prefer class‑ or suite‑level container lifecycles to reuse a single container.
AI-written summary · about
chapters (12)
- 0:00Introduction
- 1:51What are Testcontainers
- 8:33Transforming integration testing
- 12:36Avoid host/port hardcoding
- 16:45Never hardcode container names
- 19:40Replace sleep with waits
- 24:20Use Testcontainers modules
- 31:07Avoid latest tag
- 34:46Optimize container lifecycle
- 45:06Spring Boot integration
- 55:32Summary
- 58:10Q&A
related talks
43mRemoving complexity from integration tests using Testcontainers!
15mTestcontainers: Simplify Your Integration Tests and Development
53mTestcontainers: a year-in-review
46mTestcontainers - The past, the present and the future
51mMastering Testcontainers for better integration tests
28mPostmortem: TDD with TestContainers
21mTest Containers: Where Every Test Starts Fresh
45mTestcontainers - a Year-in-review
