Unit Testing and Software Design

This is the other side of the coin when it comes to the relationship between the main code and unit testing: good software is testable software.

Importance of test-driven design

Testability—the quality attribute that determines how easy to test software is—is not just nice to have, but a driver for clean code.

Unit tests aren’t just complementary to the main code base, but are rather something that has a direct impact and real influence on how the code is written. There are many levels of this; from the very beginning, when we realize that the moment we want to add unit tests for some parts of our code we have to change it (resulting in a better version of it), to its ultimate expression (explored near the end of this chapter) when the entire code (the design) is driven by the way it’s going to be tested via test-driven design.

Get hands-on with 1200+ tech skills courses.