Containerized Integration Testing with Testcontainers
Create robust integration test suites with real databases in Docker containers and contract verification.
Configure ephemeral Testcontainers instances (PostgreSQL, Redis, Kafka) to execute real database integration tests during CI without in-memory mocking.
Execution Workflow Procedure
Ordered steps the coding agent executes when performing this skill.
Configure Ephemeral Container Lifecycle
Set up Testcontainers with dynamic port allocation and automated schema migrations on test startup.
Execute End-to-End Persistence Flows
Execute full API-to-database flows, asserting database table records and foreign keys directly after API requests.
Stub Third-Party HTTP Services
Use WireMock or MSW to mock external partner APIs and verify request payloads and timeout handling.
Agent Safety Guardrails & Anti-Hallucination Rules
- DO NOT use in-memory H2 databases for testing PostgreSQL-specific SQL features (JSONB, CTEs).
- DO NOT hardcode host container ports that collide during parallel CI runs.
Expected Output Format
Complete Testcontainers-backed test class with WireMock stubs.
Domain Verification Checks
Example Agent Invocations
Install / Configure This Skill
# Place in .cursorrules or create .cursor/rules/containerized-integration-testing.mdc # Trigger: Whenever you perform containerized integration testing with testcontainers --- name: containerized-integration-testing description: Build production-grade integration test suites using Testcontainers for real database and queue testing. version: 1.0.0 compatibility: [Cursor, Claude Code, Cline, Roo Code, Antigravity] --- # Containerized Integration Testing with Testcontainers ## Objective Eliminate false-confidence in-memory mocks by testing against real containerized databases (PostgreSQL, Redis, Kafka). ## Workflow 1. **Container Setup**: Configure Testcontainers with dynamic port binding and automatic migration execution. 2. **Flow Verification**: Execute HTTP requests and assert database row state directly. 3. **External Stubs**: Mock third-party APIs using WireMock or MSW to verify payload contracts.
Need a quick one-time prompt for chat?
Try the Integration & Contract Test Plan (Testcontainers / Playwright) — a lightweight version designed for 1-click copying directly into Claude, ChatGPT, or Cursor chat.
SprintKit Workflow Integrations
Complementary tools and checklists to pair with this agent workflow.
Related Agent Skills
Explore related procedural workflows in this discipline.
Comprehensive Unit Test Suite Generation (AAA Pattern)
Generate mutation-tested unit tests with Arrange-Act-Assert structure, boundary cases, and proper mock boundaries.
Spring Boot Service & JPA Code Review
Rigorous code review workflow for Spring Boot services examining transactions, JPA queries, concurrency, and validation.
Flaky CI Test & Async Timing Resolution
Fix nondeterministic test failures, unhandled async promises, and race conditions in Playwright, Jest, or Vitest.