Zire Golf - Shop now
Buy new:
$129.33
FREE delivery July 3 - 9
Ships from: DeckleEdge LLC
Sold by: DeckleEdge LLC
$129.33
FREE delivery July 3 - 9. Details
Or fastest delivery July 2 - 7. Details
Usually ships within 5 to 6 days
$$129.33 () Includes selected options. Includes initial monthly payment and selected options. Details
Price
Subtotal
$$129.33
Subtotal
Initial payment breakdown
Shipping cost, delivery date, and order total (including tax) shown at checkout.
Ships from
DeckleEdge LLC
DeckleEdge LLC
Ships from
DeckleEdge LLC
Returns
30-day refund/replacement
30-day refund/replacement
This item can be returned in its original condition for a full refund or replacement within 30 days of receipt. You may receive a partial or no refund on used, damaged or materially different returns.
Payment
Secure transaction
Your transaction is secure
We work hard to protect your security and privacy. Our payment security system encrypts your information during transmission. We don’t share your credit card details with third-party sellers, and we don’t sell your information to others. Learn more
$79.85
FREE Returns
No highlighting/underlining. Minor wear. No highlighting/underlining. Minor wear. See less
$$129.33 () Includes selected options. Includes initial monthly payment and selected options. Details
Price
Subtotal
$$129.33
Subtotal
Initial payment breakdown
Shipping cost, delivery date, and order total (including tax) shown at checkout.
Access codes and supplements are not guaranteed with used items.
Kindle app logo image

Download the free Kindle app and start reading Kindle books instantly on your smartphone, tablet, or computer - no Kindle device required.

Read instantly on your browser with Kindle for Web.

Using your mobile phone camera - scan the code below and download the Kindle app.

QR code to download the Kindle App

Follow the author

Something went wrong. Please try your request again later.

xUnit Test Patterns: Refactoring Test Code 1st Edition

4.6 out of 5 stars 78 ratings

{"desktop_buybox_group_1":[{"displayPrice":"$129.33","priceAmount":129.33,"currencySymbol":"$","integerValue":"129","decimalSeparator":".","fractionalValue":"33","symbolPosition":"left","hasSpace":false,"showFractionalPartIfEmpty":true,"offerListingId":"AZ8SKQql%2B2tU%2FLbpwCLhTA7EOeI3TUrMaz1hUxygAaqaIbe1qEZVg3FgbohhsYyeMZjj95IlVIMnTazYtOBWp5XOBJKg%2F835RIJYI5zYyOF1hKz27qcr1PF6j46WZAAE1s8BzSDD7E9B5haL6eRPok76Sj1iOR4WFBOiV3crtYMBYYDq0Men3g%3D%3D","locale":"en-US","buyingOptionType":"NEW","aapiBuyingOptionIndex":0}, {"displayPrice":"$79.85","priceAmount":79.85,"currencySymbol":"$","integerValue":"79","decimalSeparator":".","fractionalValue":"85","symbolPosition":"left","hasSpace":false,"showFractionalPartIfEmpty":true,"offerListingId":"AZ8SKQql%2B2tU%2FLbpwCLhTA7EOeI3TUrM9LRrTBFjQukD2GYMm6VPqLSFIhUdKMN90yS9I46uSyKSoFdVi8msUwx5AeMr5niP8I7nYUqqJFPUORZaKBcLr5xgQ1QjgPtLKfbb9g7zsXaM4twULodp0R0zro9sdrECmxerrdfW4%2BTKtPZcwrGrNw%3D%3D","locale":"en-US","buyingOptionType":"USED","aapiBuyingOptionIndex":1}]}

Purchase options and add-ons

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 a unique and unfamiliar challenge.

xUnit Test Patterns is the definitive guide to writing automated tests using xUnit, the most popular unit testing framework in use today. Agile coach and test automation expert Gerard Meszaros describes 68 proven patterns for making tests easier to write, understand, and maintain. He then shows you how to make them more robust and repeatable--and far more cost-effective.

Loaded with information, this book feels like three books in one. The first part is a detailed tutorial on test automation that covers everything from test strategy to in-depth test coding. The second part, a catalog of 18 frequently encountered "test smells," provides trouble-shooting guidelines to help you determine the root cause of problems and the most applicable patterns. The third part contains detailed descriptions of each pattern, including refactoring instructions illustrated by extensive code samples in multiple programming languages.

Topics covered include

  • Writing better tests--and writing them faster
  • The four phases of automated tests: fixture setup, exercising the system under test, result verification, and fixture teardown
  • Improving test coverage by isolating software from its environment using Test Stubs and Mock Objects
  • Designing software for greater testability
  • Using test "smells" (including code smells, behavior smells, and project smells) to spot problems and know when and how to eliminate them
  • Refactoring tests for greater simplicity, robustness, and execution speed

This book will benefit developers, managers, and testers working with any agile or conventional development process, whether doing test-driven development or writing the tests last. While the patterns and smells are especially applicable to all members of the xUnit family, they also apply to next-generation behavior-driven development frameworks such as RSpec and JBehave and to other kinds of test automation tools, including recorded test tools and data-driven test tools such as Fit and FitNesse.


Visual Summary of the Pattern Language
Foreword

Preface

Acknowledgments

Introduction

Refactoring a Test

PART I: The Narratives
Chapter 1 A Brief Tour
Chapter 2 Test Smells
Chapter 3 Goals of Test Automation
Chapter 4 Philosophy of Test Automation
Chapter 5 Principles of Test Automation
Chapter 6 Test Automation Strategy
Chapter 7 xUnit Basics
Chapter 8 Transient Fixture Management
Chapter 9 Persistent Fixture Management
Chapter 10 Result Verification
Chapter 11 Using Test Doubles
Chapter 12 Organizing Our Tests
Chapter 13 Testing with Databases
Chapter 14 A Roadmap to Effective Test Automation
PART II: The Test Smells
Chapter 15 Code Smells
Chapter 16 Behavior Smells
Chapter 17 Project Smells
PART III: The Patterns
Chapter 18 Test Strategy Patterns
Chapter 19 xUnit Basics Patterns
Chapter 20 Fixture Setup Patterns
Chapter 21 Result Verification Patterns
Chapter 22 Fixture Teardown Patterns
Chapter 23 Test Double Patterns
Chapter 24 Test Organization Patterns
Chapter 25 Database Patterns
Chapter 26 Design-for-Testability Patterns
Chapter 27 Value Patterns
PART IV: Appendixes
Appendix A Test Refactorings
Appendix B xUnit Terminology
Appendix C xUnit Family Members
Appendix D Tools
Appendix E Goals and Principles
Appendix F Smells, Aliases, and Causes
Appendix G Patterns, Aliases, and Variations
Glossary
References

Index


Frequently bought together

This item: xUnit Test Patterns: Refactoring Test Code
$129.33
Get it Jul 3 - 9
Usually ships within 5 to 6 days
Ships from and sold by DeckleEdge LLC.
+
$22.27
Only 1 left in stock - order soon.
Ships from and sold by KICRI AMERICANO.
+
$49.24
Get it as soon as Saturday, Jun 21
In Stock
Ships from and sold by Amazon.com.
Total price: $00
To see our price, add these items to your cart.
Details
Added to Cart
Some of these items ship sooner than the others.
Choose items to buy together.

Editorial Reviews

From the Back Cover

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 a unique and unfamiliar challenge.

xUnit Test Patterns is the definitive guide to writing automated tests using xUnit, the most popular unit testing framework in use today. Agile coach and test automation expert Gerard Meszaros describes 68 proven patterns for making tests easier to write, understand, and maintain. He then shows you how to make them more robust and repeatable--and far more cost-effective.

Loaded with information, this book feels like three books in one. The first part is a detailed tutorial on test automation that covers everything from test strategy to in-depth test coding. The second part, a catalog of 18 frequently encountered "test smells," provides trouble-shooting guidelines to help you determine the root cause of problems and the most applicable patterns. The third part contains detailed descriptions of each pattern, including refactoring instructions illustrated by extensive code samples in multiple programming languages.

Topics covered include

  • Writing better tests--and writing them faster
  • The four phases of automated tests: fixture setup, exercising the system under test, result verification, and fixture teardown
  • Improving test coverage by isolating software from its environment using Test Stubs and Mock Objects
  • Designing software for greater testability
  • Using test "smells" (including code smells, behavior smells, and project smells) to spot problems and know when and how to eliminate them
  • Refactoring tests for greater simplicity, robustness, and execution speed

This book will benefit developers, managers, and testers working with any agile or conventional development process, whether doing test-driven development or writing the tests last. While the patterns and smells are especially applicable to all members of the xUnit family, they also apply to next-generation behavior-driven development frameworks such as RSpec and JBehave and to other kinds of test automation tools, including recorded test tools and data-driven test tools such as Fit and FitNesse.


Visual Summary of the Pattern Language
Foreword

Preface

Acknowledgments

Introduction

Refactoring a Test

PART I: The Narratives
Chapter 1 A Brief Tour
Chapter 2 Test Smells
Chapter 3 Goals of Test Automation
Chapter 4 Philosophy of Test Automation
Chapter 5 Principles of Test Automation
Chapter 6 Test Automation Strategy
Chapter 7 xUnit Basics
Chapter 8 Transient Fixture Management
Chapter 9 Persistent Fixture Management
Chapter 10 Result Verification
Chapter 11 Using Test Doubles
Chapter 12 Organizing Our Tests
Chapter 13 Testing with Databases
Chapter 14 A Roadmap to Effective Test Automation
PART II: The Test Smells
Chapter 15 Code Smells
Chapter 16 Behavior Smells
Chapter 17 Project Smells
PART III: The Patterns
Chapter 18 Test Strategy Patterns
Chapter 19 xUnit Basics Patterns
Chapter 20 Fixture Setup Patterns
Chapter 21 Result Verification Patterns
Chapter 22 Fixture Teardown Patterns
Chapter 23 Test Double Patterns
Chapter 24 Test Organization Patterns
Chapter 25 Database Patterns
Chapter 26 Design-for-Testability Patterns
Chapter 27 Value Patterns
PART IV: Appendixes
Appendix A Test Refactorings
Appendix B xUnit Terminology
Appendix C xUnit Family Members
Appendix D Tools
Appendix E Goals and Principles
Appendix F Smells, Aliases, and Causes
Appendix G Patterns, Aliases, and Variations
Glossary
References

About the Author

Gerard Meszaros is Chief Scientist and Senior Consultant at ClearStream Consulting, a Calgary-based consultancy specializing in agile development. He has more than a decade of experience with automated unit testing frameworks and is a leading expert in test automation patterns, refactoring of software and tests, and design for testability.

Product details

  • Publisher ‏ : ‎ Addison-Wesley
  • Publication date ‏ : ‎ January 1, 2007
  • Edition ‏ : ‎ 1st
  • Language ‏ : ‎ English
  • Print length ‏ : ‎ 833 pages
  • ISBN-10 ‏ : ‎ 0131495054
  • ISBN-13 ‏ : ‎ 978-0131495050
  • Item Weight ‏ : ‎ 3.3 pounds
  • Dimensions ‏ : ‎ 7.25 x 2 x 9.5 inches
  • Customer Reviews:
    4.6 out of 5 stars 78 ratings

About the author

Follow authors to get new release updates, plus improved recommendations.
Gerard Meszaros
Brief content visible, double tap to read full content.
Full content visible, double tap to read brief content.

Discover more of the author’s books, see similar authors, read book recommendations and more.

Customer reviews

4.6 out of 5 stars
78 global ratings

Review this product

Share your thoughts with other customers

Customers say

Customers find the book to be an unparalleled exegesis of unit testing, providing guidance on how to approach testing and writing clean test code. They consider it a great value for money, with one customer noting that the first part of the book is particularly excellent.

11 customers mention "Testing knowledge"11 positive0 negative

Customers praise the book's comprehensive approach to unit testing, providing unparalleled guidance on patterns and strategies, with one customer noting it's the most thorough book on writing well-structured unit tests.

"...book to read if you want to really understand the xUnit tools, automated testing, and best practices when using them...." Read more

"...The parts I've gone through are extremely well presented and I have already learned a lot from them...." Read more

"...The first chapter in part three is test strategy patterns, describing different approaches to testing (and this one is not specific to xUnit tests)...." Read more

"...An amazingly thorough analysis of how to validate software. A timeless volume because it teaches concepts, and is not tied to any framework...." Read more

8 customers mention "Value for money"8 positive0 negative

Customers find the book to be good value for money, with one customer noting that the first part is particularly excellent.

"...It's a lengthy book, but well worth the read if you want to write better tests, or if you want to develop an xUnit framework...." Read more

"...The first part of the book is excellent. It contains a couple of chapters related to test automation that are not specific to xUnit test automation...." Read more

"Good book, I keep it on my desk at work...." Read more

"This book looks very promising, but the Kindle edition (that I purchased) has formatting issues with the code examples...." Read more

Top reviews from the United States

  • Reviewed in the United States on March 11, 2016
    Format: HardcoverVerified Purchase
    The book to read if you want to really understand the xUnit tools, automated testing, and best practices when using them. Even though it was written a number of years ago, it's still very relevant today. Mr. Meszaros obviously has a real depth of experience in testing that he pulls from for this volume. It's a lengthy book, but well worth the read if you want to write better tests, or if you want to develop an xUnit framework. He refers often to Martin Fowler's Refactoring, as well as other books such as the GOF Patterns book, so it might be good to have those handy or read them as well. I will say, it took me quite a while to finally get through this whole book but I was glad I did and read through all of the patterns as well as the "smells". Good stuff, and thanks to Gerard for putting so much time and effort into compiling this volume.
    One person found this helpful
    Report
  • Reviewed in the United States on May 8, 2025
    Format: HardcoverVerified Purchase
    I read this book as part of a book club at work and found it very insightful!
  • Reviewed in the United States on March 9, 2013
    Format: HardcoverVerified Purchase
    Like the rest of the books in Martin Fowler's signature series, this is an authoritative work on the important subject of unit testing. This is, however, a big book (900 odd pages) and I have no intention of reading it cover to cover. The parts I've gone through are extremely well presented and I have already learned a lot from them. For example, what's the difference between a mock and a stub? The book does have areas of redundancy. For example, there's a fair bit of overlap between chapters 11 (Using Test Doubles) and 23 (Test Double Patterns). I hope I never have to eat these words, but so far I've experienced that investing in a Martin Fowler series book always pays off big time, often in ways you don't imagine. For example, I didn't think that a book on unit test patterns would help to reinforce my concepts on types of inversion of control (IoC) or refactoring, but it did!
    2 people found this helpful
    Report
  • Reviewed in the United States on June 23, 2009
    Format: HardcoverVerified Purchase
    xUnit Test Patterns by Gerard Meszaros is a huge book. It is almost 900 pages of patterns to be used for test automation and for unit testing. This book contains a huge amount of useful knowledge for developers and is, without a doubt, the most thorough book on writing well-structured unit tests. The largest drawback of the book is its size and the amount of duplication.

    The book consists of three parts. The first part is normal prose introducing the patterns and their contexts. The second part is a catalog of test smells and the last part (which is most of the book) describes the test patterns.

    The first part of the book is excellent. It contains a couple of chapters related to test automation that are not specific to xUnit test automation. Chapter two introduces test smells, which I found very helpful. Chapter three contains the goals of test automation. This was one of the clearest descriptions I've seen which answer the question "why do we want to do this in the first place." The next chapters are about philosophy (e.g. TDD), principles and strategy. Chapter second introduces xUnit basics and the rest of the chapters of this part are narratives around the pattern sets (chapters) which are introduces further on in the book. The first part is about 180 pages of the book and is definitively worth reading completely. The individual chapters are short and easy to read.

    The second part of the book covers test smells. The test smells are grouped intro three categories: code smells, behavior smells and project smells. These smells are also linked to each other, explaining what the "higher level smell" is caused by. I'm afraid I've seen all the smells in real life in the past and thus this part was very recognizable. Nowadays, I often send these smells to people I work with, since Gerard described them perhaps better than I ever could. The test smells are less than a hundred pages

    The third part of the book are the test patterns. They are grouped in 'test pattern categories' with each category containing as little as four and as much as ten patterns. The pattern format Gerard uses is clear and easy to read. The largest drawback is that the pattern format causes quite a lot of duplication, especially across patterns. This is because the book is written so that each pattern can be read independently of others. This is good, but for people who read whole books (me) it causes the book to be somewhat boring to read (even though the content is interesting, just felt bored when reading again that there is one exception to object per test-case implementation of most xUnit frameworks).

    The first chapter in part three is test strategy patterns, describing different approaches to testing (and this one is not specific to xUnit tests). The next chapter introduces xUnit frameworks written down in pattern form. Fixture setup is next in which the author describes the advantages and disadvantages for fresh vs shared fixtures and how to set them up. Chapter 21 then dives into the assertion parts of an xUnit framework describing the difference between state and behavior verification. Patterns such as custom assertions are frequently used in well-written test code. Next are the teardown patterns in which the authors somewhat promote the automated teardown (something I've not encountered very often in development). Chapter 23 is probably one of the best known chapters where Gerard categorizes test doubles (mocks/stubs/fakes) and describes when to use which term and why? This terminology is far from standardized and his effort to bring clarity in these terms is much appreciated. Next are test organization patterns such as how and where do you split your test case. Chapter 25 covers working with databases. Chapter 26 some general miscellaneous pattern in design which promote low coupling and thus increase testability. The final chapter relates to values within your tests.

    The book also (for if this wasn't enough for you) contains over a hundred pages of appendixes. The refactorings, terminology mapping and glossary are useful.

    Gerards book is huge. It contains useful insights related to unit testing and writing clean test code. From that perspective, this book is recommended for everyone serious about writing well-factored unit tests. However, the book also contains relative trivial things and, as mentioned, it contains a huge amount of duplication between different parts. This means that perhaps reading the book from cover to cover might not be the best approach :) Part one and two should definitively be read completely, but the patterns in chapter 3 are better browsed and read when needed or e.g. one per week. Another annoying part in the book, for me, was the way Gerard uses comments. Most comments in the code were not useful and made the code obscure and hard to read at times. Wished he had left them out (though, I guess this relates to coding style a lot).

    Conclusion. Definitively worth reading or at least browsing for anyone serious about xUnit and test automation. Because of the duplication and the comments, I'd rate it four out of five stars. Personally I'd rather see a small 100 page book containing the summary and conclusions of what Gerard is talking about. It doesn't exist yet, so this book is, at this moment, the best on this particular subject.
    10 people found this helpful
    Report
  • Reviewed in the United States on May 1, 2017
    Format: HardcoverVerified Purchase
    Every software test engineer should learn this book. Every software developer would rise high above their peers if they understand these concepts. A tour de force of software test automation. As to complaints about length and repetition, read the first half as a story, and use the second half as a reference. An amazingly thorough analysis of how to validate software. A timeless volume because it teaches concepts, and is not tied to any framework. The title is misleading because the book is not primarily about xUnit test patterns or refactoring. If you learn this book, you'll never want for work as a software test engineer.
    2 people found this helpful
    Report
  • Reviewed in the United States on May 23, 2014
    Lots of customers I help either have no tests or have tests that exercise the HOW instead of the WHAT (intent, API). When they change implementation details, the tests break. Bad smells in code can also be present in test code. This book will help you avoid many pitfalls. I had the pleasure of working alongside Gerard in a consulting gig at Cognos (now IBM) and it was a pleasure to work with him. His seminar is also great (I attended his seminar in Ottawa/ON/Canada). You need this book to do proper testing instead of having tests that become weight around your neck.
  • Reviewed in the United States on October 3, 2015
    Format: KindleVerified Purchase
    A decent listing of patterns, though it has a high amount of repitition and is mostly common sense. Still, it's language agnostic and is useful for someone new to testing to get exposure to the various ways of testing things.
    One person found this helpful
    Report
  • Reviewed in the United States on August 6, 2013
    Format: KindleVerified Purchase
    This book has definitely changed the way I write software and my approach towards tests.

    I had seen this book around for a while and never picked it up, thinking "oh, I know enough xUnit..." and believing it to be a reference on various xUnit frameworks. That's not what it is. This book will show you how to approach testing, what smells to look out for and how to avoid them by using well established testing patterns.

    Every developer should have this book by their side.

Top reviews from other countries

Translate all reviews to English
  • Antonio Foranna
    4.0 out of 5 stars Buono
    Reviewed in Italy on April 21, 2013
    Format: HardcoverVerified Purchase
    Interessante, chiaro ed esaustivo ma molto prolisso e ripetitivo, per cui potrebbe scocciare leggerlo tutto.
    In definitiva un buon libro.
    Report
  • Nicholas Roeder
    5.0 out of 5 stars Comprehensive
    Reviewed in Canada on August 3, 2007
    Format: HardcoverVerified Purchase
    This book is advertised as "three books in one" which I originally figured was just the usual publisher's marketing. But it really delivers in all three areas: introductory narratives, discussion of test code smells, and of course, the testing patterns themselves.

    Even if you have done automated unit testing using any of the xUnit frameworks in the past, it will be useful to read the introductory narratives. Meszaros accomplishes the difficult task of clearly describing all of the aspects of xUnit including fixture management. I say "difficult", because it can be hard to document something that is so familiar that you do every day. Even though most of this content is not new, it provides clear terminology, which is valuable in making the rest of the book understandable.

    Mezaros writes in a clear and highly detailed style and the book appears suprisingly free of typos and grammatical errors, which is a nice change for technical books.

    Don't be scared by the size of the book. There isn't anything unnecessary here, and even the glossary is comprehensive and useful.

    Highly recommended!
  • Fabiano C. de Oliveira
    5.0 out of 5 stars Testes unitários de fácil manutenção
    Reviewed in Brazil on March 20, 2019
    Format: KindleVerified Purchase
    Este livro é altamente recomendado para todos que procuram desenvolver um software de qualidade. Independentemente se você é um desenvolvedor experiente ou não este livro apresenta dicas valiosíssimas na construção de uma suíte de testes confiável, de fácil manutenção e que possibilita a aplicação das metodologias Agile no desenvolvimento de software.

    O livro é denso sim mas isso só mostra o zelo e a pesquisa exaustiva que o autor fez. É muito claro que a obra é um resumo da experiência de VARIAS equipes na construção de uma suíte de testes de qualidade. Isso é importante pois embora possa parecer paradoxal o uso de testes automatizados, sem o uso de boas práticas (exemplificadas à exaustão no livro), pode dificultar a manutenção e evolução do sistema. Tanto é assim que o autor dá testemunho de sua própria experiência em projetos.

    O livro apresenta o que se deve fazer para não cair na armadilha de testes automatizados que no médio ou longo prazo mais atrapalha do que ajuda. São dicas valiosíssimas que dão segurança a prática dos testes que deveria ser mais aplicada. Essa obra é uma excelente contribuição para a área de desenvolvimento de software.
  • The Daddy
    5.0 out of 5 stars Assert awesome
    Reviewed in Canada on February 22, 2019
    Format: KindleVerified Purchase
    Excellent book. When your code sense already tells you what makes a good test or a bad one, xUnit Test Patterns can explain why.
  • Kogaratsu
    4.0 out of 5 stars Référence unique dans le domaine
    Reviewed in France on October 21, 2012
    Format: HardcoverVerified Purchase
    L'auteur est le seul à avoir traité le sujet de manière aussi complète ! Le catalogue de patterns est énorme. La lecture reste aisée car les patterns sont bien organisés. Même si la mise en pratique n'est pas évidente, le livre permet de bien clarifier les idées sur la manière d'écrire de bons tests, et dans quel contexte.
    Il manque peut-être un chapitre sur les techniques de Mock (Mockito, JMockIt...) permettant d'aller au delà des patterns présentés.