Test-Driven Development (TDD) is een praktijk waarbij je tests schrijft voordat je code schrijft — volgens een kort, zich herhalende cyclus: schrijf een falende test, schrijf code om die te laten slagen, en refactor vervolgens. Het stuurt ontwerp via tests en zorgt ervoor dat code testbaar en goed getest is.
De TDD-cyclus: Rood, Groen, Refactoren
1. RED → write a FAILING test for the behavior you want (it fails — the code doesn't exist yet)
2. GREEN → write the MINIMUM code to make the test PASS (just enough, don't over-build)
3. REFACTOR → improve/clean up the code (and tests) while keeping tests GREEN
→ Repeat this short cycle for each small piece of behavior.
Write test (RED) → write code (GREEN) → clean up (REFACTOR) → repeat
