We can view TDD as an iterative cycle with five steps:
A developer writes a test for a new feature based on specifications.
The developer runs all existing tests. The newly created test should fail because the code for its feature hasn’t been written yet. This validates that the test was needed.
The developer writes the simplest code needed to get the test to pass.
The developer refactors the new code to improve the code’s readability and maintainability.
The developer repeats the process, eventually collecting new tests for every intended feature of the code.