Overview

TDD follows a short, repetitive cycle often called 'Red-Green-Refactor'. It ensures that the code is testable and meets the requirements from the start.

The Cycle

  1. Red: Write a test for a small bit of functionality and watch it fail.
  2. Green: Write the simplest code possible to make the test pass.
  3. Refactor: Clean up the code while ensuring the test still passes.

Benefits

  • High test coverage.
  • Better software design.
  • Reduced bug count in production.

Related Terms