Red-green-refactor, also called the TDD cycle, is the loop at the heart of test-driven development: write a failing test (red), write just enough code to make it pass (green), then improve the code without changing its behaviour (refactor).
Why it matters: The cycle gives developers fast feedback on the design of their code. The tests it leaves behind are a useful side effect, though they don't guarantee complete safety or confidence.
In practice: Testers can work alongside the cycle. Before the failing test is written, they help decide what it should be. During green, they think through edge cases and explore new code. During refactor, they review testability and coverage with the developers.
Examples:
- A tester exploring new code on a developer's machine during the green stage.
- Reviewing test coverage with developers during refactoring.
Common pitfalls:
- Skipping the refactor step, so code quality slowly degrades.
- Treating TDD's unit tests as all the testing needed.
What role do testers play in TDD? Testers help decide what to test, explore the code as it's written, think about edge cases and user behaviour, and collaborate on where each test belongs.