TDD is a software development methodology where tests are written before the code they are intended to test.
Its purpose is to reduce the number of bugs early on and to increase testability.
It follows a short, iterative cycle:
Its purpose is to reduce the number of bugs early on and to increase testability.
It follows a short, iterative cycle:
- Write a test that fails because the code doesn't exist yet.
- Write a minimal amount of code to make the test pass.
- Refactor both the test and the code to improve quality.
- Repeat.
TDD helps to ensure that code is testable, well-designed and meets its requirements.