Book
xUnit Test Patterns
Refactoring Test Code
Gerard Meszaros
Summary
A pattern catalog for automated test code written with xUnit-family frameworks. The publisher says it feels like three books in one. The first part is a narrative tutorial: goals, philosophy and principles of test automation, test strategy, xUnit basics, transient and persistent fixture management, result verification, test doubles, test organization, and testing with databases. The second part catalogs 18 test smells, grouped as code smells, behavior smells and project smells, with guidance for tracing each to its cause. The third part describes 68 patterns in detail, from fixture setup and teardown to test doubles and design for testability, with refactoring instructions and code samples in several programming languages.
Target Readers
- Developers who write automated tests with an xUnit-family framework, whether test-first or test-last
- Testers and managers on teams that use automated tests in an agile or conventional development process
Tags
Colophon
- Publisher
- Addison-Wesley Professional
- ISBN
- 978-0-13-149505-0
- Published
- May 2007
Get this book
* The link above is an advertisement via Amazon Associates.Related Books
Prerequisites
- Recommended
Test-Driven Development
Kent Beck
Reason: Test-Driven Development: By Example builds the habit of writing tests first, through a multi-currency exercise and a small xUnit framework written from scratch. xUnit Test Patterns takes the resulting test code as its subject: it organizes fixture setup and teardown, result verification and test doubles as patterns, and uses a catalog of 18 test smells to trace problems to their causes. It belongs after the habit is in place, when the tests have to be kept maintainable.
Next Books
- Related
Unit Testing Principles, Practices, and Patterns
Vladimir Khorikov
Reason: xUnit Test Patterns lays out how test code can be written as 68 patterns and 18 smells, aiming at coverage of the options. Unit Testing Principles, Practices, and Patterns gives a vocabulary for judging whether an individual test is worth keeping, built on four pillars: protection against regressions, resistance to refactoring, fast feedback and maintainability. Knowing the options for test doubles and fixtures from the first book, you can use the four pillars of the second to compare them.