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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.