Integration & Contract Test Plan (Testcontainers / Playwright)
Create robust integration test suites with real databases in Docker containers and contract verification.
Interactive Prompt Playground
{{SERVICE_CODE}}{{DEPENDENCIES}}{{FRAMEWORK}}You are a Lead QA Automation Engineer specializing in modern integration testing with Testcontainers, WireMock, and real database instances.
Service / Integration Under Test:
```
@RestController
@RequestMapping("/api/v1/customers")
public class CustomerController {
private final CustomerRepository repository;
private final EmailClient emailClient;
@PostMapping
@ResponseStatus(HttpStatus.CREATED)
public Customer create(@RequestBody @Valid CustomerRequest req) {
Customer c = repository.save(new Customer(req.name(), req.email()));
emailClient.sendWelcome(c.getEmail());
return c;
}
}
```
External Dependencies: PostgreSQL 16 Database + Third-Party Email HTTP API
Test Framework: Spring Boot 3.3 Test + Testcontainers PostgreSQL + WireMock
Design and generate a production-ready integration test suite:
1. **Containerized Test Lifecycle**:
- Configure ephemeral containers (e.g. PostgreSQL, Redis, Kafka via Testcontainers).
- Ensure clean database schema migrations (Flyway/Liquibase/Prisma) run automatically on test startup.
2. **End-to-End Workflow Verification**:
- Write integration tests executing full user journeys (HTTP Request -> Service -> DB -> Event Emission).
- Assert database row states directly after API calls.
3. **External API Mocking (WireMock / MSW)**:
- Stub external third-party HTTP services (Stripe, Twilio) verifying request headers and handling 5xx error scenarios.
4. **State Cleanup & Concurrency**:
- Ensure tests can run in parallel without cross-test data pollution (transaction rollback or database truncation).
Provide the complete integration test class implementation.How to Use This Prompt
- Paste your backend controller or data layer.
- List all external databases and APIs the service touches.
- Get a complete Testcontainers-backed integration test class.
Engineering Tips & Best Practices
- Use @DynamicPropertySource in Spring Boot or global setup in Vitest to dynamically bind container ports.
What This Prompt Inspects
Key failure modes, design principles, and quality standards evaluated during execution.
Real Container Instances
Replaces in-memory H2 mocks with real PostgreSQL containers matching production.
External Stub Validation
Verifies outgoing HTTP payloads sent to third-party endpoints.
Parallel Isolation
Configures dynamic database ports to avoid port collision during CI.
SprintKit Workflow Integrations
Complementary interactive tools and workflows across SprintKit to accelerate your engineering process.
Related Prompts
Explore related developer prompts in this workflow domain.
Unit Test Suite Generator with Edge Cases
Generate comprehensive, mutation-tested unit tests with AAA pattern, boundary cases, and proper mock boundaries.
Spring Boot REST Service & JPA Code Review
Deep code review for Spring Boot services examining transaction boundaries, JPA N+1 queries, concurrency, and validation.
Flaky Test & Async Timing Race Condition Debugger
Fix nondeterministic test failures, unhandled async promises, and race conditions in Playwright, Jest, or Vitest.