Adam can be contacted at email@example.com.
xUnit Test Patterns: Refactoring Test Code
883 pps, $54.99
From a quality assurance and testing perspective, the greatest advance in how software is build in the last decade is the widespread use of unit testing frameworks. An application with a rich set of unit tests raises the bar of initial quality when it is given to testing groups, thereby letting them spend more time finding the difficult bugs or those which cannot be automated. Unfortunately, with this rise in test code has been a tandem rise in the complexity and fragility of the test code base, which in some organizations can of upwards of 70 percent or more of production lines-of-code (LOC). Gerard Meszaros' xUnit Test Patterns is about how to effectively create and manage your unit tests.
Meszaro divides the book into two parts:
- The first is titled "The Narratives" and makes up the first quarter of the book. Here he discusses test automation principles, strategies and organization of test code. This section should be considered mandatory reading for all developers who are creating unit tests. It should also be recommended reading for people working in QA/Test roles as they need to be the champions of unit testing and advocate for constantly improving tests.
- The other three quarters of the book is more developer-centric and deals with Patterns. The Patterns section coverage is further subdivided into three sections: smells (symptoms of a problem), test patterns (a starting point for writing good, robust automated tests), and test organization patterns (to help make test code easy to understand and find). Each pattern contains a description, some variations of the pattern you might encounter, and an example of the pattern in Java. The Patterns section is not meant to be read front-to-back. Instead, the backcover lists all the patterns in the context of which problems they solve. When you encounter a problem (Which fixture strategy should we use? How do we implement Behavior Verification?) with your unit tests you can quickly look up the pattern (or patterns) which address it and can concentrate on those that are relevant to your current needs.
At one point I worked as a test lead at a company which made use of the Stub Test Double in its application to remove the dependency of partner systems being available which saved out release dates on more than one occasion. We also used started writing automate GUI tests against the stubbed version with much success. In talking with other organizations about the use of Test Doubles, I often hear things like "We tried that for a while, but the scripts kept breaking" or "We are not sure where we should use a Mock." It was those sorts of questions which lead me to xUnit Test Patterns and it's coverage of Object Doubles (Stubs, Spies, Mocks and Fakes). These patterns are the most important part of the book.
I highly recommend this book and see it becoming required reading for both test and development teams. Automated unit tests are an essential part of today's mature development environment. This book will help teams make their existing tests more robust, more extensible and of higher quality. If you are not yet writing test code, xUnit Test Patterns will help you do it right the first time.