Browse the Knowledge Hub211 resources
xUnit Test Patterns: is it worth reading?
The reference catalogue of test patterns and smells, and the source of the test double vocabulary everyone uses.
We earn nothing from any link on this page. No affiliate links anywhere in this library.
- published
- 2007
- key ideas
- 3

xUnit Test Patterns
Refactoring Test Code
by Gerard Meszaros
- Publisher
- Addison-Wesley
- Year
- 2007
- ISBN
- 9780321504807
Useful when you are: Senior / lead
Verdict
Should you read it?
Read it if
You own a large test suite with problems you can feel but cannot name. The smell catalogue gives you the vocabulary to diagnose and discuss them.
Skip it if
You are looking for a readable introduction. It is nearly 900 pages of catalogue and reads like one.
The argument
What it argues
Meszaros catalogues the recurring patterns in automated test code and, more usefully, the smells: tests that are fragile, obscure, slow, or that produce erratic failures. Each gets a name, a diagnosis and a remedy.
Its most lasting contribution is the test double taxonomy. Dummy, stub, spy, mock and fake were loosely and inconsistently used before this book; the distinctions it drew are now the standard vocabulary.
It is a reference work rather than a book to read through, and should be treated as one.
Key ideas
Ideas worth taking from it
- 01
The test double taxonomy
Dummy, stub, spy, mock, fake. Precise definitions for terms that were previously used interchangeably, and the vocabulary the whole industry adopted.
- 02
Test smells
Named, diagnosable problems in test code: fragile test, obscure test, erratic test, test code duplication. Naming them makes them discussable in review.
- 03
Tests as first-class code
Test code deserves the same design attention as production code, and the patterns for achieving that are different from production patterns.
Criticism
What has dated, and what it gets wrong
Enormous, and the length is genuinely off-putting. The Java and xUnit framing shows its 2007 origins, and the patterns around fixture setup are less relevant given modern framework features. Use the online pattern catalogue rather than the book unless you need the depth.
Keep reading
What to read next
Reads well with
More in Unit testing & TDD
Reading about quality is cheaper than learning it in production.
QAble runs QA for products in BFSI, gaming, healthcare and SaaS, with engineers who have read these and argued about them. Start with a free QA audit.



