The Red-Green-Refactor cycle
- Red — write a test for new behaviour. It fails because the code does not exist yet
- Green — write the minimum code to make the test pass. Any way works
- Refactor — improve the code without changing behaviour. The test stays green
Benefits
- New code is 100% covered by definition
- Design naturally becomes testable — no tight dependencies
- Tests document behaviour
Criticism
Slows initial development. Hard to apply to UI, legacy code, and integrations. Most teams use TDD selectively, not universally.