Test-driven development is a testing methodology that focuses on encouraging developers to write tests before they write application code. Usually, the process of writing code in TDD consists of the following basic steps:
- Write a test that fails. There is no application code at this point, so the test should fail.
- Run the test and ensure that it fails.
- Write the code to pass the test.
- Run the test and ensure that it works.
- Run all the other existing tests to ensure that no other parts of the application are broken because of the changes.
- Repeat the process for every new feature or bug fix.
This process is often represented as the "red-green-refactor" diagram:
The choice between using TDD or not comes down ...