Real Integration Tests with TestContainers
summary
Demonstrates running throwaway Docker-backed integration tests for Elasticsearch using TestContainers and a Maven plugin, showing a real test that spins an ES container, indexes one document and asserts a single hit. Builds a tiny Java wrapper (~150 lines) around the official image, waits ~20 seconds for JVM startup, and tears down containers automatically so tests are isolated (one container per test) or reused via a static block. Notes pitfalls: deprecated Docker Hub images, port collisions, and no easy Docker-in-Docker solution. TestContainers docker start test 150 lines of wrapper
AI-written summary · about
chapters (18)
- 0:00Introduction and personal intro
- 1:23Why integration tests matter
- 3:06Mocking vs real integration tests
- 5:12Using real data stores
- 5:54Live demo with Elasticsearch
- 8:25Standalone dependency issues
- 10:10In-process solutions like Flapdoodle
- 11:56Maven Docker plugin approach
- 14:28Docker Maven plugin limitations
- 16:47TestContainers introduction
- 17:51How TestContainers works
- 19:15Customizing TestContainers for Elasticsearch
- 21:02TestContainers demo in action
- 22:52TestContainers reuse and cleanup
- 23:34Why mocking fails for integration tests
- 24:18Build tool integration trade-offs
- 25:22Q&A session begins
- 35:19Closing remarks
related talks
14mTestcontainers for Real Integration Tests [...]
48mContainers for Real Integration Tests
51mTestContainers: Integration Testing Without the Hassle
26mRemoving Complexity from Integration Tests Using Testcontainers
19mTestcontainers for real Elasticsearch integration tests
47mIntegration Tests: testcontainers to the Rescue
27mIntegration testing for Microservices with Docker and TestContainers
14mIntegration testing your legacy java microservice with docker-maven-plugin
