Book
Unit Testing Principles, Practices, and Patterns
Vladimir Khorikov
Summary
Vladimir Khorikov gives a vocabulary for judging whether a test is actually worth keeping, built around four pillars: protection against regressions, resistance to refactoring, fast feedback, and maintainability. It isn't an introduction to testing basics. It assumes you already write tests, then pushes into mock overuse, brittle assertions, and the anti-patterns that quietly erode a suite's value over time. Examples are in C#, but the reasoning is language-agnostic, and later chapters extend the same four-pillar framework to integration and database tests.
Target Readers
- Developers who already write unit tests but suspect their suite is brittle or slow, and want a framework for diagnosing why
- Engineers who over-rely on mocks and want a principled way to decide when a mock helps versus when it just couples the test to implementation details
- Teams introducing integration tests alongside unit tests and needing a shared standard for what makes either one worth keeping
Tags
Colophon
- Publisher
- Mynavi Publishing
- ISBN
- 978-4839981723
- Published
- Dec 2022
- List price
- ¥4,488incl. taxMay differ from the actual selling price on Amazon
Get this book
* The link above is an advertisement via Amazon Associates.Related Books
Prerequisites
- Recommended
Clean Architecture
A Craftsman's Guide to Software Structure and Design
Robert C. Martin
Reason: Learning an architecture that controls the direction of dependencies makes you want testing principles that maximize the resulting testability. Unit Testing: Principles, Practices, and Patterns defines what a good test is, converting the loose coupling your architecture enables into testing value.
Sources
- Recommended
Spring Tettei Nyumon (A Thorough Introduction to Spring)
Java Application Development with the Spring Framework
NTT Data
Reason: Once you can write applications with Spring, you learn the principles for writing unit tests that guarantee their behavior correctly. Understanding not just the quantity of tests but their quality—what to verify and what to mock—lets you grow a test suite that is resilient to change and not brittle.
- Recommended
Test-Driven Development
Kent Beck
Reason: Once the small TDD cycle makes writing working tests second nature, you advance to principles of what and at what granularity to test. Good tests are resistant to refactoring, do not get in its way, and reliably catch regressions.
- Related
xUnit Test Patterns
Refactoring Test Code
Gerard Meszaros
Reason: xUnit Test Patterns lays out how test code can be written as 68 patterns and 18 smells, aiming at coverage of the options. Unit Testing Principles, Practices, and Patterns gives a vocabulary for judging whether an individual test is worth keeping, built on four pillars: protection against regressions, resistance to refactoring, fast feedback and maintainability. Knowing the options for test doubles and fixtures from the first book, you can use the four pillars of the second to compare them.
Next Books
- Recommended
Testing Web APIs
Mark Winteringham
Reason: Having mastered unit testing principles, you broaden your view to a testing strategy for APIs that cross service boundaries. Testing Web APIs shows how to balance the upper layers of the test pyramid—integration, contract, end-to-end—securing the API reliability that unit tests alone can't protect.
- Recommended
Effective Software Testing
A developer's guide
Maurício Aniche
Reason: After grasping the qualities of good tests—protection against regressions, resistance to refactoring, fast feedback—you raise the question of what to test with systematic techniques like boundary analysis, equivalence partitioning, and structural testing. Case selection moves from intuition to engineering.
- Recommended
Full Stack Testing
A Practical Guide for Delivering High Quality Software
Gayathri Mohan
Reason: Once unit tests form a solid base, you stack integration, contract, and end-to-end tests in the right proportions along the test pyramid, scaling up to a system-wide quality strategy. The rule is many at the bottom, few at the top.
- Recommended
Frontend Kaihatsu no Tame no Test Nyumon (An Introduction to Testing for Frontend Development)
Essential Knowledge of Automated Testing Strategy, Worth Learning Even Now
Takefumi Yoshii
Reason: The principles of test design carry over to the frontend. Building on the test pyramid, you cover the essentials of the UI with a few end-to-end tests and protect logic densely with unit tests—the criteria stay the same across layers.
- Related
Working Effectively with Legacy Code
Michael C. Feathers
Reason: After grasping the principles of good tests, you apply them to legacy code that resists testing. You introduce seams to break dependencies and pin current behavior with characterization tests before changing it safely.
- Related
Growing Object-Oriented Software, Guided by Tests
Steve Freeman, Nat Pryce
Reason: Once you can judge the quality of an individual test, you extend to a design approach that grows object responsibilities and collaboration through tests. Choosing the right test double becomes feedback on the design itself.