"Those who read, live a thousand lives before they die. Those who never read only live one."

Book cover of 'Writing Maintainable Unit Tests'

Writing Maintainable Unit Tests

Mastering the art of loosely coupled unit tests

Are unit tests causing you pain? Are they constantly failing whenever you make changes to your production code? Do you spend a lot of time fixing them when they break? Are they difficult to set up and run? Do you have a hard time maintaining or structuring your unit test code? Are they causing you headaches from time to time? Are you ready to give up on writing unit tests or have you already done so?

Or do you just want to step up your game and want to learn more about how to write readable and maintainable unit tests?

This book is for experienced software developers who want to improve upon their existing skills in writing unit tests. You will learn how to build loosely coupled, highly maintainable and robust unit tests that are trustworthy and improve the overall code quality of your software applications. The content of this book is based on 15+ years of experience with Test-Driven Development.

Although the examples in this book are written in C#, the principles and guidance are broadly applicable to other platforms and programming environments as well (Java, Python, JavaScript, etc.). You will be able to universally apply this knowledge throughout the rest of your career.

The book contains six chapters:

  • Chapter 1 provides an overview of the different kinds of automated tests and how to apply a healthy mix in a code base. It also touches on the different flavours of Test-Driven Development.
  • Chapter 2 describes the characteristics and principles that make tests maintainable. It touches on a number of design principles like DRY, DAMP and the Single-Responsibility Principle.
  • Chapter 3 discusses the anatomy of automated tests and how a good structure is essential to keep them readable for our fellow software developers.
  • Chapter 4 demonstrates a number of patterns and techniques to keep tests decoupled from the production code. This is the longest chapter of the book.
  • Chapter 5 shows a number of patterns and techniques for writing clear assertions and observations.
  • Chapter 6 touches on some miscellaneous principles that are useful for writing maintainable and readable tests.

For more information, you can have a look at the full table of contents.


Thank you for visiting my website. I’m a professional software developer since Y2K. A blogger since Y2K+5. Author of Writing Maintainable Unit Tests. Provider of training and coaching in XP practices. Curator of the Awesome Talks list. Thinking and learning about all kinds of technologies since forever.

Contact information

(+32) 496 38 00 82