XUnit test patterns : refactoring test code
Contents
Visual Summary of the Pattern Language
Foreword
Preface
Acknowledgments
Introduction
Refactoring a Test
PART I. The Narratives
Chapter 1. A Brief Tour
About This Chapter
The Simplest Test Automation Strategy That Could Possibly Work
What’s Next?
Chapter 2. Test Smells
About This Chapter
An Introduction to Test Smells
A Catalog of Smells
What’s Next?
Chapter 3. Goals of Test Automation
About This Chapter
Why Test?
Goals of Test Automation
What’s Next?
Chapter 4. Philosophy of Test Automation
About This Chapter
Why Is Philosophy Important?
Some Philosophical Differences
When Philosophies Differ
My Philosophy
What’s Next?
Chapter 5. Principles of Test Automation
About This Chapter
The Principles
What’s Next?
Chapter 6. Test Automation Strategy
About This Chapter
What’s Strategic?
Which Kinds of Tests Should We Automate?
Which Tools Do We Use to Automate Which Tests?
Which Test Fixture Strategy Do We Use?
How Do We Ensure Testability?
What’s Next?
Chapter 7. xUnit Basics
About This Chapter
An Introduction to xUnit
Common Features
The Bare Minimum
Under the xUnit Covers
xUnit in the Procedural World
What’s Next?
Chapter 8. Transient Fixture Management
About This Chapter
Test Fixture Terminology
Building Fresh Fixtures
Tearing Down Transient Fresh Fixtures
What’s Next?
Chapter 9. Persistent Fixture Management
About This Chapter
Managing Persistent Fresh Fixtures
Managing Shared Fixtures
What’s Next?
Chapter 10. Result Verification
About This Chapter
Making Tests Self-Checking
State Verification
Verifying Behavior
Reducing Test Code Duplication
Avoiding Conditional Test Logic
Other Techniques
Where to Put Reusable Verification Logic?
What’s Next?
Chapter 11. Using Test Doubles
About This Chapter
What Are Indirect Inputs and Outputs?
Testing with Doubles
Other Uses of Test Doubles
Other Considerations
What’s Next?
Chapter 12. Organizing Our Tests
About This Chapter
Basic xUnit Mechanisms
Right-Sizing Test Methods
Test Methods and Testcase Classes
Test Naming Conventions
Organizing Test Suites
Test Code Reuse
Test File Organization
What’s Next?
Chapter 13. Testing with Databases
About This Chapter
Testing with Databases
Testing without Databases
Testing the Database
Testing with Databases (Again!)
What’s Next?
Chapter 14. A Roadmap to Effective Test Automation
About This Chapter
Test Automation Difficulty
Roadmap to Highly Maintainable Automated Tests
What’s Next?
PART II. The Test Smells
Chapter 15. Code Smells
Obscure Test
Conditional Test Logic
Hard-to-Test Code
Test Code Duplication
Test Logic in Production
Chapter 16. Behavior Smells
Assertion Roulette
Erratic Test
Fragile Test
Frequent Debugging
Manual Intervention
Slow Tests
Chapter 17. Project Smells
Buggy Tests
Developers Not Writing Tests
High Test Maintenance Cost
Production Bugs
PART III. The Patterns
Chapter 18. Test Strategy Patterns
Recorded Test
Scripted Test
Data-Driven Test
Test Automation Framework
Minimal Fixture
Standard Fixture
Fresh Fixture
Shared Fixture
Back Door Manipulation
Layer Test
Chapter 19. xUnit Basics Patterns
Test Method
Four-Phase Test
Assertion Method
Assertion Message
Testcase Class
Test Runner
Testcase Object
Test Suite Object
Test Discovery
Test Enumeration
Test Selection
Chapter 20. Fixture Setup Patterns
In-line Setup
Delegated Setup
Creation Method
Implicit Setup
Prebuilt Fixture
Lazy Setup
Suite Fixture Setup
Setup Decorator
Chained Tests
Chapter 21. Result Verification Patterns
State Verification
Behavior Verification
Custom Assertion
Delta Assertion
Guard Assertion
Unfinished Test Assertion
Chapter 22. Fixture Teardown Patterns
Garbage-Collected Teardown
Automated Teardown
In-line Teardown
Implicit Teardown
Chapter 23. Test Double Patterns
Test Double
Test Stub
Test Spy
Mock Object
Fake Object
Configurable Test Double
Hard-Coded Test Double
Test-Specific Subclass
Chapter 24. Test Organization Patterns
Named Test Suite
Test Utility Method
Parameterized Test
Testcase Class per Class
Testcase Class per Feature
Testcase Class per Fixture
Testcase Superclass
Test Helper
Chapter 25. Database Patterns
Database Sandbox
Stored Procedure Test
Table Truncation Teardown
Transaction Rollback Teardown
Chapter 26. Design-for-Testability Patterns
Dependency Injection
Dependency Lookup
Humble Object
Test Hook
Chapter 27. Value Patterns
Literal Value
Derived Value
Generated Value
Dummy Object
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
A
B
C
D
E
F
G
H
I
L
M
N
O
P
R
S
T
U
V
References
Index
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X