Complete testing workflow covering all phases from test creation to validation, regression prevention, resilience testing, and E2E patterns.
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: testing3description: Complete testing workflow - test creation, validation, regression prevention, resilience, and E2E patterns4---56Complete testing workflow covering all phases from test creation to validation, regression prevention, resilience testing, and E2E patterns.78## Testing Workflow Phases910### 1. Test Creation (TDD Red Phase)1112Write failing tests BEFORE implementation based on requirements.1314**Process:**151. Parse requirement - Read user story, identify functionality, extract acceptance criteria162. Identify test cases - Happy path, error cases, edge cases, boundary conditions, invalid inputs173. Write failing tests - Create test file, write test functions with descriptive names, assert expected behavior184. Verify tests fail - Run tests, confirm they fail for the RIGHT reason (not syntax errors, but because functionality doesn't exist)195. Document expected behavior - Test names describe what should happen, comments link to requirements2021**Test Types:**22- Unit Tests - Individual functions/methods in isolation23- Integration Tests - Component interactions24- Contract Tests - API boundaries25- Acceptance Tests - Business requirements2627**Best Practices:**28- Test one thing per test29- Use descriptive names (e.g., `test_user_registration_creates_account`)30- Arrange-Act-Assert structure31- No implementation - tests only32- Verify failure before implementing33- Link to requirements in comments3435### 2. Acceptance Validation3637Validates that implementation meets business requirements and acceptance criteria.3839**Process:**401. Parse original requirement - Extract business need and acceptance criteria412. Map criteria to tests - Link each criterion to specific test(s)423. Verify all criteria met - Run tests and confirm each passes434. Generate acceptance report - Create report showing criteria status4445**Acceptance Criteria Formats:**46- User Story Format: "As a [role] I want [feature] So that [benefit]"47- Given-When-Then Format: "Given [context] When [action] Then [outcome]"4849**Validation Checks:**50- All criteria have tests51- All tests pass52- Tests match criteria (verify test actually tests the criterion)53- Edge cases covered (negative, boundary, performance)5455**Output Format:**56- Requirement summary57- Criteria status table (✅/❌/⚠️)58- Overall verdict (ACCEPTED/REJECTED/PARTIAL)59- Test coverage percentage60- Outstanding issues61- Recommendations6263### 3. Regression Prevention6465Ensures changes don't break existing functionality by verifying all tests pass and coverage doesn't decrease.6667**Checks Performed:**681. All existing tests pass - Every test must pass before changes accepted692. Coverage doesn't decrease - Code coverage should not drop below current level703. No new warnings - New code should not introduce warnings714. Performance benchmarks maintained - Critical operations should not become slower725. API contracts unchanged - Public APIs should remain compatible7374**Blocking Conditions:**75Changes are BLOCKED if:76- ❌ Any test failure77- ❌ Coverage drop > 2%78- ❌ New deprecation warnings79- ❌ Performance regression > 10%80- ❌ Breaking API changes (unintentional)8182**Workflow:**83- Before Changes: Run all tests, measure coverage baseline, run performance benchmarks84- After Changes: Run all tests, compare results with baseline, check coverage hasn't dropped, verify performance maintained8586**Best Practices:**87- Run regression checks before every commit88- Maintain high test coverage (>80%)89- Fix flaky tests immediately90- Monitor performance trends91- Keep tests fast92- Test in isolation93- Version APIs for graceful deprecation9495### 4. Resilience Testing9697Tests system resilience - error handling, edge cases, load, recovery.9899**Resilience Categories:**1001. Error Handling - Invalid inputs, type mismatches, missing fields1012. Network Resilience - Timeouts, transient failures, circuit breakers1023. Database Resilience - Connection failures, transaction rollbacks, deadlocks1034. Load Resilience - Concurrent requests, rate limiting, queue overflow1045. Recovery & Idempotency - State recovery, graceful degradation, idempotent operations1056. Edge Cases & Boundaries - Empty input, large input, boundary values, unicode106107**Test Patterns:**108- Retry Pattern - Exponential backoff on failures109- Circuit Breaker - Fail fast when service is down110- Bulkhead - Isolate failures to prevent cascading111112**Best Practices:**113- Test failure scenarios, not just happy path114- Use realistic failures (network timeouts, database errors)115- Test recovery mechanisms116- Test under load (concurrent requests, high volume)117- Test boundaries (min/max values, empty inputs)118- Test idempotency119- Verify error messages are clear and actionable120121### 5. E2E Testing Patterns122123End-to-end testing patterns and examples for browser, API, and CLI workflows.124125**Test Types:**126- Browser-Based E2E (Playwright) - Full UI workflows testing complete user journeys127- API-Based E2E - Complete API workflows from authentication to data operations128- CLI-Based E2E - Command-line workflows from initialization to deployment129130**Test Patterns:**131- Happy Path Test - Test successful completion of user workflow132- Error Recovery Test - Test user recovery from error scenarios133- Multi-User Scenario - Test collaborative workflows with multiple users134135**Best Practices:**136- Test real user flows, not just API endpoints137- Use realistic test data138- Test error scenarios, not just happy path139- Keep tests independent140- Clean up after tests141- Run against staging environment142- Monitor test duration143- Use page objects for browser tests144- Verify visual elements with screenshots145- Test accessibility146147## Complete TDD Workflow1481491. **Red:** Create failing tests (Test Creation phase)1502. **Green:** Implement minimum code to pass tests1513. **Refactor:** Improve code while keeping tests green1524. **Resilience:** Add error handling and edge case tests (Resilience Testing phase)1535. **Validate:** Verify acceptance criteria met (Acceptance Validation phase)1546. **Guard:** Ensure no regressions (Regression Prevention phase)1557. **E2E:** Validate complete user flows (E2E Testing Patterns phase)156157See `docs/TDD-METHODOLOGY.md` for detailed TDD methodology guide including Red-Green-Refactor cycle, todo creation templates, best practices, and common mistakes.158159See examples.md for complete code examples and patterns.