Test-Driven Development: Why the Test Comes Before the Code
Writing the test first proves it can actually fail before you trust it to catch a regression. Here is the red-green-refactor cycle, a worked example, and the cases where TDD stops paying for itself.