Cover of XUnit Test Patterns

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.

Mentions per year

20 2007: 0 mentions2008: 0 mentions2009: 1 mention2010: 0 mentions2011: 0 mentions2012: 1 mention2013: 0 mentions2014: 0 mentions2015: 0 mentions2016: 1 mention2017: 2 mentions2018: 0 mentions2019: 0 mentions2020: 0 mentions2021: 0 mentions2022: 2 mentions2023: 0 mentions2024: 0 mentions2025: 1 mention2026: 0 mentions200720172026

What Hacker News says

  • cessor · Nov 15, 2016 · Recommends

    …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)” ↗
  • cenny · Mar 21, 2022 · Recommends

    …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” ↗
  • praptak · Jul 1, 2009 · Recommends

    "xUnit Test Patterns: Refactoring Test Code" by Gerard Meszaros, http://xunitpatterns.com/

    on “Why unit testing is a waste of time” ↗
  • laxk · Mar 15, 2012 · Recommends

    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.

  • cessor · Jun 5, 2017 · Recommends

    …"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?” ↗
  • TeMPOraL · Nov 5, 2022 · Recommends

    > 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” ↗
  • Kerrick · Nov 29, 2025 · Mentions

    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” ↗
  • arye_lu · Aug 9, 2017 · Mentions

    A retake on xUnit Test Patterns by Gerard Meszaros

    on “The Art of Test Patterns – Slides” ↗

Keyboard shortcuts

/
Focus search
j / k
Next / previous book
Enter
Open focused book
Esc
Close / go back
g h
Go to Home
g t
Go to Top all-time
g m
Go to Most recommended
g r
Go to Rising
g f
Go to For You
?
Show this help