Definition. Test-Driven Development

[comp1110-41]

Test-driven development (TDD) is a practice where tests are written before the implementation. The workflow is:

  1. Write a test for the behaviour you want
  2. Watch it fail (since there is no implementation yet)
  3. Write the minimum implementation to make it pass
  4. Repeat

This encourages thinking carefully about what a piece of code should do before thinking about how it should work. It also ensures that every piece of behaviour has a test from the start.

bars magnifying-glass caret-down plus minus arrow-right xmark