Mocks vs Testcontainers
summary
Compares Testcontainers (real services in Docker) with mocks (fast in-memory fakes), showing concrete tradeoffs: Testcontainers reproduce production behavior but add slow pulls, require Docker and flaky startup times; mocks start instantly, let tests inject failures and verify calls, but often miss protocol corner cases (Redis mock lacked some commands). Kafka examples show a synchronous test driver that can give false confidence for async streams; Awaitility speeds and stabilizes async checks but cannot remove fundamental flakiness. Recommends mixing tools and preferring emulators when available over relying only on H2.
AI-written summary · about
chapters (11)
- 0:00Introduction
- 2:13Mocks vs Testcontainers
- 6:08Integration tests
- 11:05Mocks versus real systems
- 18:26Preliminary considerations
- 19:09Example 1: Redis and JetBrains Xodus
- 23:55Example 2: Kafka and Testcontainers
- 33:18Example 3: Apache Beam and DirectRunner
- 40:03Example 4: Celesta as mock backend
- 48:57Summary
- 52:32Q&A
related talks
37mFrom mocking to rocking your tests with testcontainers
26mSimplify Your Dev Life with Testcontainers
46mRemoving complexity from integration tests using Testcontainers!
33mMock Me If You Can: Using Mocks in Container Applications for Integration Testing
47mIntegration Tests: testcontainers to the Rescue
01h 06mTestcontainers best practices.
53mTestcontainers: a year-in-review
46mTestcontainers - The past, the present and the future
