
XUnit Test Patterns
by Gerard Meszaros · first published 2007
8mentions
5recommended by
7HN commenters
2009–2025first – last mentioned
71% recommend29% neutral
Why HN recommends it
Catalogs named test patterns and smells, with fine-grained distinctions such as mocks versus stubs; recommended for anyone starting to write tests regularly and for developers who want a vocabulary for test code.
Summarised by Claude from recommending comments
Automated testing is a cornerstone of agile development. An effective testing strategy will deliver new functionality more aggressively, accelerate user feedback, and improve quality. However, for many developers, creating effective automated tests is
Affiliate links. As an Amazon Associate I earn from qualifying purchases.






…Rhino Mocks asked for ridiculous code like var format = MockRepository.GenerateStub<IFormatCode>(); (Which one is it, a Mock or a Stub? And: Does it matter?) I recommend Gerard Meszaros excellent book XUnit Test Patterns, he makes more fine grained distinctions between different aspects of testing. I liked his notion that you simply create objects that produce or react to "indirect input and output" (i.e. exceptions,…
on “Mocks Aren't Stubs (2007)” ↗…and TDD. I wished more people would read Kent Becks book [Test-Driven Development: by example](https://www.programmingbooks.dev/#test-driven-development) and then the amazing book by Gerard Meszaros [XUnit Test Patterns](https://www.programmingbooks.dev/#xunit-test-patterns). In the end I'm just happy if more people practice TDD and understand it's a skill to learn like everything else and not a silver bullet.
on “The Big TDD Misunderstanding” ↗"xUnit Test Patterns: Refactoring Test Code" by Gerard Meszaros, http://xunitpatterns.com/
on “Why unit testing is a waste of time” ↗I highly recommend this book "xUnit Test Patterns: Refactoring Test Code" (http://www.amazon.com/xUnit-Test-Patterns-Refactoring-Code/d...) to anyone who wants to start to use tests on daily basis.
…"Working Effectively With Legacy Code" - Michael Feathers - "Growing OO Software, Guided by tests" - Pryce, Freeman - "Test Driven Development" by Kent Beck And, this last one I can't recommend enough: "XUnit Test Patterns" by Gerard Meszaros Kent Beck's TDD is good book to start with. Even if you feel like you have got testing figured out, you should try TDD. It has more to do with discipline and getting things done,…
on “Ask HN: What language-agnostic programming books should I read?” ↗> The excellent book xUnit Test Patterns describes a test smell named Assertion Roulette. It describes situations where it may be difficult to determine exactly which assertion caused a test failure. How is that even possible in the first place?…
on “Multiple assertions are fine in a unit test” ↗I am indeed learning, working to close those gaps. For automated testing, I'm in the middle of reading Developer Testing by Alexander Tarlinder, with xUnit Test Patterns by Gerard Meszaros coming close behind. I'm also working through Test-Driven Development: By Example with my wife as we have time. For SQL, I read Grokking Relational Database Design by Qiang Hao last…
on “Confessions of a Software Developer: No More Self-Censorship” ↗A retake on xUnit Test Patterns by Gerard Meszaros
on “The Art of Test Patterns – Slides” ↗