Laws of Software Engineering · Practice

Practice

Test-Driven Development

Write the test first. Write only enough code to make it pass. Refactor. Repeat.

How to use it. The discipline is in the order: test first, code second, refactor third. Done well, it produces code that is testable by construction and design that emerges through pressure.

How it gets misused. Treated as a coverage strategy. TDD is about the order in which you write tests, and the number of tests is beside the point. Teams that write tests after the code are doing something useful, but it is not TDD, and the design benefits do not transfer.

Related