Ir al contenido

Translations:TDD/2/en

De Scrum Manager BoK

The practice is attributed to Kent Beck, who described it as a core part of Extreme Programming (1999) and developed it in detail in his book Test-Driven Development: By Example (2003). Beck described TDD as a way to produce simple designs and inspire trust in the code.

The red-green-refactor cycle

The TDD cycle is usually described with three colors:

  • Red: write a test that fails because the functionality does not exist yet. The failing (red) test is the starting point: it defines what the code must do.
  • Green: write the minimum code needed to make the test pass. Only the minimum code: nothing more, even if it looks "ugly" or provisional.
  • Refactor: improve the internal structure of the code without changing its external behavior. The tests ensure that the refactoring has not broken anything.

This cycle lasts minutes, not hours. The discipline of staying in short cycles is what makes TDD effective.