Log In
Or create an account ->
Imperial Library
Home
About
News
Upload
Forum
Help
Login/SignUp
Index
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
Development Process
Customer Tests
Unit Tests
Design for Testability
Test Organization
What's Next?
Chapter 2. Test Smells
About This Chapter
An Introduction to Test Smells
What's a Test Smell?
Kinds of Test Smells
What to Do about Smells?
A Catalog of Smells
The Project Smells
The Behavior Smells
The Code Smells
What's Next?
Chapter 3. Goals of Test Automation
About This Chapter
Why Test?
Economics of Test Automation
Goals of Test Automation
Tests Should Help Us Improve Quality
Tests Should Help Us Understand the SUT
Tests Should Reduce (and Not Introduce) Risk
Tests Should Be Easy to Run
Tests Should Be Easy to Write and Maintain
Tests Should Require Minimal Maintenance as the System Evolves Around Them
What's Next?
Chapter 4. Philosophy of Test Automation
About This Chapter
Why Is Philosophy Important?
Some Philosophical Differences
Test First or Last?
Tests or Examples?
Test-by-Test or Test All-at-Once?
Outside-In or Inside-Out?
State or Behavior Verification?
Fixture Design Upfront or Test-by-Test?
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?
Per-Functionality Tests
Cross-Functional Tests
Which Tools Do We Use to Automate Which Tests?
Test Automation Ways and Means
Introducing xUnit
The xUnit Sweet Spot
Which Test Fixture Strategy Do We Use?
What Is a Fixture?
Major Fixture Strategies
Transient Fresh Fixtures
Persistent Fresh Fixtures
Shared Fixture Strategies
How Do We Ensure Testability?
Test Last—at Your Peril
Design for Testability—Upfront
Test-Driven Testability
Control Points and Observation Points
Interaction Styles and Testability Patterns
Divide and Test
What's Next?
Chapter 7. xUnit Basics
About This Chapter
An Introduction to xUnit
Common Features
The Bare Minimum
Defining Tests
What's a Fixture?
Defining Suites of Tests
Running Tests
Test Results
Under the xUnit Covers
Test Commands
Test Suite Objects
xUnit in the Procedural World
What's Next?
Chapter 8. Transient Fixture Management
About This Chapter
Test Fixture Terminology
What Is a Fixture?
What Is a Fresh Fixture?
What Is a Transient Fresh Fixture?
Building Fresh Fixtures
In-line Fixture Setup
Delegated Fixture Setup
Implicit Fixture Setup
Hybrid Fixture Setup
Tearing Down Transient Fresh Fixtures
What's Next?
Chapter 9. Persistent Fixture Management
About This Chapter
Managing Persistent Fresh Fixtures
What Makes Fixtures Persistent?
Issues Caused by Persistent Fresh Fixtures
Tearing Down Persistent Fresh Fixtures
Avoiding the Need for Teardown
Dealing with Slow Tests
Managing Shared Fixtures
Accessing Shared Fixtures
Triggering Shared Fixture Construction
What's Next?
Chapter 10. Result Verification
About This Chapter
Making Tests Self-Checking
Verify State or Behavior?
State Verification
Using Built-in Assertions
Delta Assertions
External Result Verification
Verifying Behavior
Procedural Behavior Verification
Expected Behavior Specification
Reducing Test Code Duplication
Expected Objects
Custom Assertions
Outcome-Describing Verification Method
Parameterized and Data-Driven Tests
Avoiding Conditional Test Logic
Eliminating "if" Statements
Eliminating Loops
Other Techniques
Working Backward, Outside-In
Using Test-Driven Development to Write Test Utility Methods
Where to Put Reusable Verification Logic?
What's Next?
Chapter 11. Using Test Doubles
About This Chapter
What Are Indirect Inputs and Outputs?
Why Do We Care about Indirect Inputs?
Why Do We Care about Indirect Outputs?
How Do We Control Indirect Inputs?
How Do We Verify Indirect Outputs?
Testing with Doubles
Types of Test Doubles
Providing the Test Double
Configuring the Test Double
Installing the Test Double
Other Uses of Test Doubles
Endoscopic Testing
Need-Driven Development
Speeding Up Fixture Setup
Speeding Up Test Execution
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
Testcase Class per Class
Testcase Class per Feature
Testcase Class per Fixture
Choosing a Test Method Organization Strategy
Test Naming Conventions
Organizing Test Suites
Running Groups of Tests
Running a Single Test
Test Code Reuse
Test Utility Method Locations
TestCase Inheritance and Reuse
Test File Organization
Built-in Self-Test
Test Packages
Test Dependencies
What's Next?
Chapter 13. Testing with Databases
About This Chapter
Testing with Databases
Why Test with Databases?
Issues with Databases
Testing without Databases
Testing the Database
Testing Stored Procedures
Testing the Data Access Layer
Ensuring Developer Independence
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
Exercise the Happy Path Code
Verify Direct Outputs of the Happy Path
Verify Alternative Paths
Verify Indirect Output Behavior
Optimize Test Execution and Maintenance
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
References
Index
← Prev
Back
Next →
← Prev
Back
Next →