Prompt file imported from cdalsoniii/brightpath-coder (
.cursor/commands/write-integration-tests.md). Copyright stays with the author.
Write Integration Tests
Overview
Generate integration tests with proper fixtures and teardown to validate cross-boundary interactions between components.
Steps
-
Identify integration points
- Map dependencies between modules/services
- Identify database interactions, API calls, message queue operations
- Determine which boundaries need integration testing
- Document expected integration behaviors
-
Set up test fixtures and test database
- Create test database schema (separate from production)
- Implement database migrations/seeding for test data
- Set up test containers or in-memory databases
- Configure test environment variables and connections
-
Write tests for cross-boundary interactions
- Test database CRUD operations with real database
- Verify API client-server communication
- Test message queue producer-consumer flows
- Validate authentication/authorization across layers
- Test transaction boundaries and rollback scenarios
-
Verify error handling across boundaries
- Test network failures and timeouts
- Verify database connection failures
- Test invalid data propagation between layers
- Ensure proper error transformation and logging
-
Clean up resources
- Implement teardown hooks to clean test data
- Reset database state between tests
- Close connections and release resources
- Use test fixtures with automatic cleanup (before/after hooks)
Checklist
- Test database is isolated from production
- Test fixtures properly set up and tear down
- Cross-boundary interactions are validated
- Error scenarios across boundaries are tested
- Resources are properly cleaned up after tests
- Tests are independent and can run in any order
- Integration tests are tagged/grouped separately from unit tests
References
- Rule:
.cursor/rules/022-integration-testing.mdc - Rule:
.cursor/rules/testing-standards.mdc - Plan:
.cursor/plans/test_strategy_quality_assurance.plan.md - Agent:
.cursor/agents/test-engineer.md
