Testing Architecture & Methodologies:
1. Test-Driven Development (TDD) - The Red-Green-Refactor Cycle:
- Red: Write a focused unit test for a desired capability before writing implementation code; verify that the test fails.
- Green: Write the minimal implementation code necessary to make the test pass cleanly.
- Refactor: Clean up and optimize the implementation while keeping all tests passing, guaranteeing behavioral correctness throughout code design.
2. The Testing Pyramid (Bottom to Top):
- Unit Tests (70% of test suite): Test isolated functions, pure utilities, and domain business logic with mocked external dependencies. Ultra-fast (milliseconds) and cheap to maintain.
- Integration Tests (20%): Verify interactions between components and real external boundaries (e.g., testing database repository queries using containerized PostgreSQL). Catches contract mismatches.
- End-to-End (E2E) Tests (10%): Test complete user journeys through the browser/UI (Cypress/Playwright) touching real backend staging services. High confidence, but slower to run and more susceptible to flakiness.