1.3. Tests as a design tool

Automated tests written by programmers have traditionally been considered a quality assurance effort targeted at the dual purposes of verifying the correctness of an implementation at the time of its writing and verifying its correctness in the future as the code base evolves. That’s using tests as a verification tool—you envision a design, write code to implement the design, and write tests to verify that you’ve implemented it correctly.

Using automated tests as a design tool turns everything upside down. When you use tests to design your code, you transform the canonical sequence of “design, code, test” into “test, code, design.” Yes, that’s right. Test comes before code, and you conclude with a retroactive design ...

Get Effective Unit Testing 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.