This is the teaser post of the original review that is pretty detailed, containing images and diagrams.
Meszaros G., xUnit Test Patterns (2007)
Extract
This book is essential language-agnostic source to make your TDD delivering principal values: maintainable test code, joyful SUT refactorings, and zero product defects.
Contents
- Summary
Concepts
- Goals of Test Automation
- Testing Philosophy
- Principles of Test Automation
Practice
Summary
While TDD by Example is more conceptual, practically demonstrating only TDD cycle, this one presents a much wider and very practical body of knowledge a software engineer must not miss.
[INFO] [xUnit](https://en.wikipedia.org/wiki/XUnit) is the family of unit testing frameworks implementing unified specific approaches and test code patternsThe family includes test frameworks for Java, C#,, JavaScript, PHP to name a few.
Despite seemingly heavy, The book is effectively organized and is a pleasure to absorb using my reviewSkim the diagrams and maps, take 1-2 techniques you like most and start applyingWhen hungry again return for moreWith time the book becomes a good foundational reference on testing.
The review combines "Part INarratives" and "Part IIIPatterns" into a single space as they discuss the same at different level on granularityPart I introduces concepts, Part III provides implementation patternsOn top the review moves the more broad concepts (goals, philosophy and principles) up.
Concepts
Goals of Test Automation
Tests should (p. 84):
- Help us to improve quality and understand the SUT.
- Reduce (and not introduce) risk.
- Be easy to run, easy to write and maintain.
- Require minimal maintenance as the system evolves around them.
Testing Philosophy
(p. 94)
- Write the tests first!
- Tests are examples (of SUT usage)!
- Usually write tests one at a time, but sometimes list all the tests one can think of as skeletons upfront.
- Outside-in development helps clarify which tests are needed for the next layer inward.
- Use primarily State Verification (p. 172, 525) but will resort to Behavior Verification (p. 531) when needed to get good code coverage.
- Perform fixture design on a test-by-test basis.
Principles of Test Automation
(p. 102)
- Write the Tests First
- Design for Testability
- Use the Front Door First
- Communicate Intent
- Don’t Modify the SUT
- Keep Tests Independent
- Isolate the SUT
- Minimize Test Overlap
- Minimize Untestable Code
- Keep Test Logic Out of Production Code
- Verify One Condition per Test
- Test Concerns Separately
- Ensure Commensurate Effort and Responsibility
Practice
Test Smells
continue at the original [review]