Test-driven development (TDD)

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:

  1. Write a test that fails. There is no application code at this point, so the test should fail.
  2. Run the test and ensure that it fails.
  3. Write the code to pass the test.
  4. Run the test and ensure that it works.
  1. Run all the other existing tests to ensure that no other parts of the application are broken because of the changes.
  2. 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 ...

Get Learning TypeScript 2.x - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.