Test-Driven Development

Test-Driven Development is a practice where you first write a failing test (red), then the minimal code to make it pass (green), then improve the code without changing the behavior (refactoring). It guides the design and provides a safety net.

Example

Red: the test fails. Green: the code makes it pass. Refactor: we clean up.

Related concepts

The whole glossary