Why this matters
- VaultCommerce CI runs 200+ Kafka integration tests per PR with Testcontainers.
- Real broker catches serializer, ACL, and protocol issues mocks miss.
- KRaft-enabled KafkaContainer matches production 3.7+ metadata mode.
- Parallel test isolation via dynamic bootstrap ports.
JUnit test
Kafka container
Assert events
JUnit 5 setup
@Testcontainers + @Container static KafkaContainer kafka = new KafkaContainer(DockerImageName.parse("confluentinc/cp-kafka:7.7.0")) or official apache/kafka-native. @DynamicPropertySource injects spring.kafka.bootstrap-servers. VaultCommerce uses singleton container per test class for speed.
Key points
- Testcontainers — Docker-based test dependencies
- KafkaContainer — ephemeral broker per test suite
- @DynamicPropertySource — wire Boot properties to container port
- Singleton container — reuse across tests in class for speed
- Schema Registry container — pair for Avro integration tests
The rest of this guide is part of Pro
Free covers every fresher guide in full. Pro unlocks Senior, Staff and Architect guides across every track.
Still to come · 2 sections
- What to test
- VaultCommerce rollout checklist
Test yourself
Answer these before moving on — recall is what makes it stick.