| name | apply-test-driven-development |
| description | Use when implementing any business logic, fixing bugs, or when the correctness of a function's behavior under various inputs needs to be proved |
| source | Kent Beck "Test Driven Development: By Example" (2002); Erdogmus et al. "On the Effectiveness of TDD" IEEE Software (2005); Beck "TDD is Dead. Long Live Testing?" debate |
| tags | ["testing","development","tdd","code-quality"] |
| verified | true |
Apply Test-Driven Development
Write a failing test before writing implementation code to drive design, prove correctness, and build a regression safety net incrementally.
Why This Is Best Practice
Adopted by: Pivotal Labs (mandated 100%), Thoughtworks, Extreme Programming practitioners; Kent Beck at Facebook; Google's internal testing culture
Impact: Erdogmus et al. IEEE Software: TDD reduces defect density by 40-80% in controlled studies; IBM case study: 40% reduction in bugs with 15-35% development time increase that is recovered in reduced debugging; Microsoft Research: 15-35% time overhead, 60-90% fewer bugs
Why best: Tests written after implementation verify what code does, not what it should do; tests written first force API design from the caller's perspective, producing simpler interfaces
Sources: Beck "Test Driven Development: By Example" Addison-Wesley (2002); Erdogmus, Morisio & Torchiano IEEE Transactions on Software Engineering (2005); George & Williams "An Initial Investigation of TDD" ACM (2003)