Bugs Are Missing Tests

Every bug exists because of a missing test in a system. The way to fix bugs using TDD is first write a failing test that represents the bug and then fix the bug and watch the failing test turn green. This not only fixes the bug but it ensures it will never come back because you have a test in place that will fail if anyone makes changes to the system that produce that bug.

Bugs in software can be grouped into several different classifications. We have syntax errors or typos, and we have more serious problems like logic errors or design flaws. Test-driven development addresses all of these issues.

Tests provide a level of feedback the compiler can’t. Traditionally, the only feedback developers got before running a program ...

Get Beyond Legacy Code 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.