TDD is an iterative software development process consisting of three steps:
- Red. Here we start by writing a failing test. It is essential to write a failing test first, because we can verify that the feature has not yet been implemented.
- Green. In this step, we aim to make the failing test pass with the simplest solution. It is crucial to keep the TDD cycle quick, so as not to lose tempo. Our aim is just to make it work.
- Refactor. In this step, we already have the functionality in our code. Given that we have added the functionality in the simplest way means the code is not in its best form. Therefore, we need to refactor the code by removing duplicated code, extracting functionality to utility methods, and adding any necessary abstractions. In general, doing any action that moves our codebase towards the appropriate design and to the code standards we have decided.