Part 3 Unit testing

 

Testing is an essential part of creating code and software that work correctly (and that keep working correctly). As discussed in chapter 1, there are different levels of testing, but unit testing is usually the one engineers interact with most in their everyday lives. This part on unit testing may be at the end of the book, but please don’t infer from this that unit testing is an add-on consideration to be addressed only after writing the code. As we saw in previous chapters, testing and testability are things we often need to consider at all times when writing code. And, as we’ll see in chapter 10, some schools of thought even go as far as to advocate that the tests should be written before writing the code.

This part of the book is split into two chapters. Chapter 10 covers some of the foundational principles of unit testing: what we’re trying to achieve, and some fundamental concepts like test doubles. Chapter 11 expands on this with a series of more practical considerations and techniques that can help us achieve the goals we identified in chapter 10.