Op werkdagen voor 23:00 besteld, morgen in huis Gratis verzending vanaf €20

xUnit Test Patterns: Refactoring Test Code

Gebonden Engels 2007 9780131495050
Verkooppositie 3281
Verwachte levertijd ongeveer 8 werkdagen


Automated testing is a cornerstone of agile development. An effective testing strategy will deliver new functionality more aggressively, accelerate user feedback, and improve quality. However, for many developers, creating effective automated tests is a unique and unfamiliar challenge.

'xUnit Test Patterns' is the definitive guide to writing automated tests using xUnit, the most popular unit testing framework in use today. Agile coach and test automation expert Gerard Meszaros describes 68 proven patterns for making tests easier to write, understand, and maintain. He then shows you how to make them more robust and repeatable--and far more cost-effective.

Loaded with information, this book feels like three books in one. The first part is a detailed tutorial on test automation that covers everything from test strategy to in-depth test coding. The second part, a catalog of 18 frequently encountered "test smells," provides trouble-shooting guidelines to help you determine the root cause of problems and the most applicable patterns. The third part contains detailed descriptions of each pattern, including refactoring instructions illustrated by extensive code samples in multiple programming languages.

Topics covered include:
- Writing better tests--and writing them faster
- The four phases of automated tests: fixture setup, exercising the system under test, result verification, and fixture teardown
- Improving test coverage by isolating software from its environment using Test Stubs and Mock Objects
- Designing software for greater testability
- Using test "smells" (including code smells, behavior smells, and project smells) to spot problems and know when and how to eliminate them
- Refactoring tests for greater simplicity, robustness, and execution speed

This book will benefit developers, managers, and testers working with any agile or conventional development process, whether doing test-driven development or writing the tests last. While the patterns and smells are especially applicable to all members of the xUnit family, they also apply to next-generation behavior-driven development frameworks such as RSpec and JBehave and to other kinds of test automation tools, including recorded test tools and data-driven test tools such as Fit and FitNesse.


Aantal pagina's:883
Hoofdrubriek:IT-management / ICT


Wees de eerste die een lezersrecensie schrijft!

Geef uw waardering

Zeer goed Goed Voldoende Matig Slecht


Visual Summary of the Pattern Language
Refactoring a Test

PART 1: 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?

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?

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?

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?

5. Principles of Test Automation
-About This Chapter
-The Principles
-What's Next?

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?

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?

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 Setu
-Delegated Fixture Setup
-Implicit Fixture Setup
-Hybrid Fixture Setup
-Tearing Down Transient Fresh Fixtures
-What's Next?

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?

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" Statement
-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?

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?

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?

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?

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 2: The Test Smells
15. Code Smells
-Obscure Test
-Conditional Test Logic
-Hard-to-Test Code
-Test Code Duplication
-Test Logic in Production

16. Behavior Smells
-Assertion Roulette
-Erratic Test
-Fragile Test
-Frequent Debugging
-Manual Intervention
-Slow Tests

17. Project Smells
-Buggy Tests
-Developers Not Writing Tests
-High Test Maintenance Cost
-Production Bugs

PART 3: The Patterns
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

19. xUnit Basics Patterns
-Test Method
-Four-Phase Test
-Assertion Method
-Assertion Message
-Testcase Class
-Test Runner
-Testcase Object
-Test Suite Object
-Test Discover
-Test Enumeration
-Test Selection

20. Fixture Setup Patterns
-In-line Setup
-Delegated Setup
-Creation Method
-Implicit Setup
-Prebuilt Fixture
-Lazy Setup
-Suite Fixture Setup
-Setup Decorator
-Chained Tests

21. Result Verification Patterns
-State Verification
-Behavior Verification
-Custom Assertion
-Delta Assertion
-Guard Assertio
-Unfinished Test Assertion

22. Fixture Teardown Patterns
-Garbage-Collected Teardown
-Automated Teardown
-In-line Teardown
-Implicit Teardown

23. Test Double
-Test Stub
-Test Spy
-Mock Object
-Fake Object
-Configurable Test Double
-Hard-Coded Test Doubl
-Test-Specific Subclass

24. Test Organization Patterns
-Named Test Suit
-Test Utility Method
-Parameterized Test
-Testcase Class per Class
-Testcase Class per Feature
-Testcase Class per Fixture
-Testcase Superclass
-Test Helper

25. Database Patterns
-Database Sandbox
-Stored Procedure Test
-Table Truncation Teardown
-Transaction Rollback Teardown

26. Design-for-Testability Patterns
-Dependency Injection
-Dependency Lookup
-Humble Object
-Test Hook

27. Value Patterns
-Literal Value
-Derived Value
-Generated Value
-Dummy Object

PART 4: 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


Alle 100 bestsellers


Populaire producten



        xUnit Test Patterns: Refactoring Test Code