Chapter 4. Concepts and patterns for TDD
I remember growing up with television, from the time it was just a test pattern, with maybe a little bit of programming once in a while.
Francis Ford Coppola
In chapters 2 and 3, we saw test-driven development being used for developing a template engine. That example was intentionally what many would consider a trivial case—a sort of “ideal” scenario with no tough cookies to crack. In this chapter, we’ll study different patterns and techniques that a seasoned test-driven developer can pull out from their toolbox when the going gets tough. These patterns range from design patterns that we can apply to our production code for making it more testable to different ways of organizing and implementing our tests. I’m about to reveal some heavily guarded secrets of the guild. Don’t tell anyone.