Write Your Tests First

Test-driven development (TDD) is a software development technique that uses really short development cycles to incrementally design your software.

Here’s how it works:

  1. Red: Before you write any new code for the system, you first write a failing unit test, showing the intent of what you would like the new code to do. Here you are thinking critically about the design.

  2. Green: Then you do whatever it takes to make the test pass. If you see the full implementation, add the new code. If you don’t, do just enough to get the test to pass.

  3. Refactor: Then you go back and clean up any code or sins you committed while trying to get the test to pass. Here you are removing duplication and making sure everything is lean, mean, ...

Get The Agile Samurai 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.