Book Review - xUnit Test Patterns: Refactoring Test Code by Gerard Meszaros
Category Book Review
By now, the concept of "patterns" in program design is pretty well accepted. And the concept of test-driven development has a solid foundation also. But are there certain "patterns" to building and running those tests? The answer is yes, and the book that covers it is xUnit Test Patterns: Refactoring Test Code by Gerard Meszaros. If you use any of the xUnit software in your development efforts, you need to have this book...
Contents:
Part 1 - The Narratives: A Brief Tour; Test Smells; Goals of Test Automation; Philosophy of Test Automation; Principles of Test Automation; Test Automation Strategy; xUnit Basics; Transient Fixture Management; Persistent Fixture Management; Result Verification; Using Test Doubles; Organizing Our Tests; Testing with Databases; A Roadmap to Effective Test Automation
Part 2 - The Test Smells: Code Smells; Behavior Smells; Project Smells
Part 3 - The Patterns: Test Strategy Patterns; xUnit Basics Patterns; Fixture Setup Patterns; Result Verification Patterns; Fixture Teardown Patterns; Test Double Patterns; Test Organization Patterns; Database Patterns; Design-for-Testability Patterns; Value Patterns
Part 4 - Appendixes: Test Refactorings; xUnit Terminology; xUnit Family Members; Tools; Goals and Principles; Smells, Aliases, and Causes; Patterns, Aliases, and Variations
Glossary; References; Index
Most of the books that cover xUnit software do so from the perspective of a technical manual. Everything is geared to writing the actual code for the test. Meszaros takes a different tack. He covers more of the "why" behind test writing in xUnit, as well as the basic patterns and principles you should be aware of when you're putting together your tests. People new to xUnit will throw together tests without much thought as to the structure and robustness of that script. Meszaros maintains that much of the same care that goes into writing and designing programs should also go into the test scripts. Patterns such as In-line Setup, Chained Tests, State Verification, and many others can adjust your whole mindset towards what makes a solid and maintainable test script that will serve you well both now and down the road when you have to make changes to the program (and add more scripts to your test suite). The book is set up such that you can scan for basic ideas, and then go back to specific patterns for more information as the situations and needs arise. With the use of both actual code and UML diagrams, it's very easy to catch the gist of each pattern, as well as seeing how it would actually be implemented. Very good stuff here...
If you practice test-driven development (and you should), you have no doubt worked with your particular xUnit variant. This book is the next step in your learning, and it will make you a much better developer and tester...
By now, the concept of "patterns" in program design is pretty well accepted. And the concept of test-driven development has a solid foundation also. But are there certain "patterns" to building and running those tests? The answer is yes, and the book that covers it is xUnit Test Patterns: Refactoring Test Code by Gerard Meszaros. If you use any of the xUnit software in your development efforts, you need to have this book...
Contents:
Part 1 - The Narratives: A Brief Tour; Test Smells; Goals of Test Automation; Philosophy of Test Automation; Principles of Test Automation; Test Automation Strategy; xUnit Basics; Transient Fixture Management; Persistent Fixture Management; Result Verification; Using Test Doubles; Organizing Our Tests; Testing with Databases; A Roadmap to Effective Test Automation
Part 2 - The Test Smells: Code Smells; Behavior Smells; Project Smells
Part 3 - The Patterns: Test Strategy Patterns; xUnit Basics Patterns; Fixture Setup Patterns; Result Verification Patterns; Fixture Teardown Patterns; Test Double Patterns; Test Organization Patterns; Database Patterns; Design-for-Testability Patterns; Value Patterns
Part 4 - Appendixes: Test Refactorings; xUnit Terminology; xUnit Family Members; Tools; Goals and Principles; Smells, Aliases, and Causes; Patterns, Aliases, and Variations
Glossary; References; Index
Most of the books that cover xUnit software do so from the perspective of a technical manual. Everything is geared to writing the actual code for the test. Meszaros takes a different tack. He covers more of the "why" behind test writing in xUnit, as well as the basic patterns and principles you should be aware of when you're putting together your tests. People new to xUnit will throw together tests without much thought as to the structure and robustness of that script. Meszaros maintains that much of the same care that goes into writing and designing programs should also go into the test scripts. Patterns such as In-line Setup, Chained Tests, State Verification, and many others can adjust your whole mindset towards what makes a solid and maintainable test script that will serve you well both now and down the road when you have to make changes to the program (and add more scripts to your test suite). The book is set up such that you can scan for basic ideas, and then go back to specific patterns for more information as the situations and needs arise. With the use of both actual code and UML diagrams, it's very easy to catch the gist of each pattern, as well as seeing how it would actually be implemented. Very good stuff here...
If you practice test-driven development (and you should), you have no doubt worked with your particular xUnit variant. This book is the next step in your learning, and it will make you a much better developer and tester...


