View all services
Talk to QA Advisor
Browse the Knowledge Hub211 resources
/Books/xUnit Test Patterns
Books · Honest notes

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

Reviewed by Viral Patel

Co-Founder, QAble

Cover of xUnit Test Patterns
Unit testing & TDD

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

  1. 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.

  2. 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.

  3. 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

Ready

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.

Talk to QA Advisor