Complete testing workflow covering all phases from test creation to validation, regression prevention, resilience testing, and E2E patterns.
Quick Reference
- Templates: See templates.md for reporting test results
Testing Workflow Phases
1. Test Creation (TDD Red Phase)
Write failing tests BEFORE implementation based on requirements.
Process:
- Parse requirement - Read user story, identify functionality, extract acceptance criteria
- Identify test cases - Happy path, error cases, edge cases, boundary conditions, invalid inputs
- Write failing tests - Create test file, write test functions with descriptive names, assert expected behavior
- Verify tests fail - Run tests, confirm they fail for the RIGHT reason (not syntax errors, but because functionality doesn't exist)
- Document expected behavior - Test names describe what should happen, comments link to requirements
Test Types:
- Unit Tests - Individual functions/methods in isolation
- Integration Tests - Component interactions
- Contract Tests - API boundaries
- Acceptance Tests - Business requirements
Best Practices:
- Test one thing per test
- Use descriptive names (e.g.,
test_user_registration_creates_account)
- Arrange-Act-Assert structure
- No implementation - tests only
- Verify failure before implementing
- Link to requirements in comments
2. Acceptance Validation
Validates that implementation meets business requirements and acceptance criteria.
Process:
- Parse original requirement - Extract business need and acceptance criteria
- Map criteria to tests - Link each criterion to specific test(s)
- Verify all criteria met - Run tests and confirm each passes
- Generate acceptance report - Create report showing criteria status
Acceptance Criteria Formats:
- User Story Format: "As a [role] I want [feature] So that [benefit]"
- Given-When-Then Format: "Given [context] When [action] Then [outcome]"
Validation Checks:
- All criteria have tests
- All tests pass
- Tests match criteria (verify test actually tests the criterion)
- Edge cases covered (negative, boundary, performance)
Output Format:
- Requirement summary
- Criteria status table (✅/❌/⚠️)
- Overall verdict (ACCEPTED/REJECTED/PARTIAL)
- Test coverage percentage
- Outstanding issues
- Recommendations
3. Regression Prevention
Ensures changes don't break existing functionality by verifying all tests pass and coverage doesn't decrease.
Checks Performed:
- All existing tests pass - Every test must pass before changes accepted
- Coverage doesn't decrease - Code coverage should not drop below current level
- No new warnings - New code should not introduce warnings
- Performance benchmarks maintained - Critical operations should not become slower
- API contracts unchanged - Public APIs should remain compatible
Blocking Conditions:
Changes are BLOCKED if:
- ❌ Any test failure
- ❌ Coverage drop > 2%
- ❌ New deprecation warnings
- ❌ Performance regression > 10%
- ❌ Breaking API changes (unintentional)
Workflow:
- Before Changes: Run all tests, measure coverage baseline, run performance benchmarks
- After Changes: Run all tests, compare results with baseline, check coverage hasn't dropped, verify performance maintained
Best Practices:
- Run regression checks before every commit
- Maintain high test coverage (>80%)
- Fix flaky tests immediately
- Monitor performance trends
- Keep tests fast
- Test in isolation
- Version APIs for graceful deprecation
4. Resilience Testing
Tests system resilience - error handling, edge cases, load, recovery.
Resilience Categories:
- Error Handling - Invalid inputs, type mismatches, missing fields
- Network Resilience - Timeouts, transient failures, circuit breakers
- Database Resilience - Connection failures, transaction rollbacks, deadlocks
- Load Resilience - Concurrent requests, rate limiting, queue overflow
- Recovery & Idempotency - State recovery, graceful degradation, idempotent operations
- Edge Cases & Boundaries - Empty input, large input, boundary values, unicode
Test Patterns:
- Retry Pattern - Exponential backoff on failures
- Circuit Breaker - Fail fast when service is down
- Bulkhead - Isolate failures to prevent cascading
Best Practices:
- Test failure scenarios, not just happy path
- Use realistic failures (network timeouts, database errors)
- Test recovery mechanisms
- Test under load (concurrent requests, high volume)
- Test boundaries (min/max values, empty inputs)
- Test idempotency
- Verify error messages are clear and actionable
5. E2E Testing Patterns
End-to-end testing patterns and examples for browser, API, and CLI workflows.
Test Types:
- Browser-Based E2E (Playwright) - Full UI workflows testing complete user journeys
- API-Based E2E - Complete API workflows from authentication to data operations
- CLI-Based E2E - Command-line workflows from initialization to deployment
Test Patterns:
- Happy Path Test - Test successful completion of user workflow
- Error Recovery Test - Test user recovery from error scenarios
- Multi-User Scenario - Test collaborative workflows with multiple users
Best Practices:
- Test real user flows, not just API endpoints
- Use realistic test data
- Test error scenarios, not just happy path
- Keep tests independent
- Clean up after tests
- Run against staging environment
- Monitor test duration
- Use page objects for browser tests
- Verify visual elements with screenshots
- Test accessibility
Complete TDD Workflow
- Red: Create failing tests (Test Creation phase)
- Green: Implement minimum code to pass tests
- Refactor: Improve code while keeping tests green
- Resilience: Add error handling and edge case tests (Resilience Testing phase)
- Validate: Verify acceptance criteria met (Acceptance Validation phase)
- Guard: Ensure no regressions (Regression Prevention phase)
- E2E: Validate complete user flows (E2E Testing Patterns phase)
See docs/TDD-METHODOLOGY.md for detailed TDD methodology guide including Red-Green-Refactor cycle, todo creation templates, best practices, and common mistakes.
See examples.md for complete code examples and patterns.
1---2name: testing-23description: Complete testing workflow covering test creation, validation, regression prevention, resilience, and E2E patterns. Use when writing tests, running test suites, or following TDD methodology.4---56Complete testing workflow covering all phases from test creation to validation, regression prevention, resilience testing, and E2E patterns.78## Quick Reference910- **Templates**: See [templates.md](templates.md) for reporting test results1112## Testing Workflow Phases1314### 1. Test Creation (TDD Red Phase)1516Write failing tests BEFORE implementation based on requirements.1718**Process:**19201. Parse requirement - Read user story, identify functionality, extract acceptance criteria212. Identify test cases - Happy path, error cases, edge cases, boundary conditions, invalid inputs223. Write failing tests - Create test file, write test functions with descriptive names, assert expected behavior234. Verify tests fail - Run tests, confirm they fail for the RIGHT reason (not syntax errors, but because functionality doesn't exist)245. Document expected behavior - Test names describe what should happen, comments link to requirements2526**Test Types:**2728- Unit Tests - Individual functions/methods in isolation29- Integration Tests - Component interactions30- Contract Tests - API boundaries31- Acceptance Tests - Business requirements3233**Best Practices:**3435- Test one thing per test36- Use descriptive names (e.g., `test_user_registration_creates_account`)37- Arrange-Act-Assert structure38- No implementation - tests only39- Verify failure before implementing40- Link to requirements in comments4142### 2. Acceptance Validation4344Validates that implementation meets business requirements and acceptance criteria.4546**Process:**47481. Parse original requirement - Extract business need and acceptance criteria492. Map criteria to tests - Link each criterion to specific test(s)503. Verify all criteria met - Run tests and confirm each passes514. Generate acceptance report - Create report showing criteria status5253**Acceptance Criteria Formats:**5455- User Story Format: "As a [role] I want [feature] So that [benefit]"56- Given-When-Then Format: "Given [context] When [action] Then [outcome]"5758**Validation Checks:**5960- All criteria have tests61- All tests pass62- Tests match criteria (verify test actually tests the criterion)63- Edge cases covered (negative, boundary, performance)6465**Output Format:**6667- Requirement summary68- Criteria status table (✅/❌/⚠️)69- Overall verdict (ACCEPTED/REJECTED/PARTIAL)70- Test coverage percentage71- Outstanding issues72- Recommendations7374### 3. Regression Prevention7576Ensures changes don't break existing functionality by verifying all tests pass and coverage doesn't decrease.7778**Checks Performed:**79801. All existing tests pass - Every test must pass before changes accepted812. Coverage doesn't decrease - Code coverage should not drop below current level823. No new warnings - New code should not introduce warnings834. Performance benchmarks maintained - Critical operations should not become slower845. API contracts unchanged - Public APIs should remain compatible8586**Blocking Conditions:**87Changes are BLOCKED if:8889- ❌ Any test failure90- ❌ Coverage drop > 2%91- ❌ New deprecation warnings92- ❌ Performance regression > 10%93- ❌ Breaking API changes (unintentional)9495**Workflow:**9697- Before Changes: Run all tests, measure coverage baseline, run performance benchmarks98- After Changes: Run all tests, compare results with baseline, check coverage hasn't dropped, verify performance maintained99100**Best Practices:**101102- Run regression checks before every commit103- Maintain high test coverage (>80%)104- Fix flaky tests immediately105- Monitor performance trends106- Keep tests fast107- Test in isolation108- Version APIs for graceful deprecation109110### 4. Resilience Testing111112Tests system resilience - error handling, edge cases, load, recovery.113114**Resilience Categories:**1151161. Error Handling - Invalid inputs, type mismatches, missing fields1172. Network Resilience - Timeouts, transient failures, circuit breakers1183. Database Resilience - Connection failures, transaction rollbacks, deadlocks1194. Load Resilience - Concurrent requests, rate limiting, queue overflow1205. Recovery & Idempotency - State recovery, graceful degradation, idempotent operations1216. Edge Cases & Boundaries - Empty input, large input, boundary values, unicode122123**Test Patterns:**124125- Retry Pattern - Exponential backoff on failures126- Circuit Breaker - Fail fast when service is down127- Bulkhead - Isolate failures to prevent cascading128129**Best Practices:**130131- Test failure scenarios, not just happy path132- Use realistic failures (network timeouts, database errors)133- Test recovery mechanisms134- Test under load (concurrent requests, high volume)135- Test boundaries (min/max values, empty inputs)136- Test idempotency137- Verify error messages are clear and actionable138139### 5. E2E Testing Patterns140141End-to-end testing patterns and examples for browser, API, and CLI workflows.142143**Test Types:**144145- Browser-Based E2E (Playwright) - Full UI workflows testing complete user journeys146- API-Based E2E - Complete API workflows from authentication to data operations147- CLI-Based E2E - Command-line workflows from initialization to deployment148149**Test Patterns:**150151- Happy Path Test - Test successful completion of user workflow152- Error Recovery Test - Test user recovery from error scenarios153- Multi-User Scenario - Test collaborative workflows with multiple users154155**Best Practices:**156157- Test real user flows, not just API endpoints158- Use realistic test data159- Test error scenarios, not just happy path160- Keep tests independent161- Clean up after tests162- Run against staging environment163- Monitor test duration164- Use page objects for browser tests165- Verify visual elements with screenshots166- Test accessibility167168## Complete TDD Workflow1691701. **Red:** Create failing tests (Test Creation phase)1712. **Green:** Implement minimum code to pass tests1723. **Refactor:** Improve code while keeping tests green1734. **Resilience:** Add error handling and edge case tests (Resilience Testing phase)1745. **Validate:** Verify acceptance criteria met (Acceptance Validation phase)1756. **Guard:** Ensure no regressions (Regression Prevention phase)1767. **E2E:** Validate complete user flows (E2E Testing Patterns phase)177178See `docs/TDD-METHODOLOGY.md` for detailed TDD methodology guide including Red-Green-Refactor cycle, todo creation templates, best practices, and common mistakes.179180See examples.md for complete code examples and patterns.