Advantages of Working This Way

The advantages of working this way, as opposed to testing last or not testing at all, are the following:

  1. It helps prevent over-engineering.

    If you apply TDD by the book, you aren’t allowed to add any production code until you have a failing test first proving that you need it. This simple act does something remarkable to code. It prevents it from becoming over-engineered.

    XP (extreme programming) has a term called Yagni,[19] or You Ain’t Gonna Need It. Meaning before you add that big hairy complex ball of spaghetti to the codebase, can you show me the failing unit test that indicates we need it first? TDD and YAGNI are how XPers keep their code solutions simple and their code humble.

  2. It tends to produce better ...

Get The Way of the Web Tester 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.