Chapter 23Test Double Patterns

Patterns in This Chapter

Test Double 522

Test Double Usage

      Test Stub 529

      Test Spy 538

      Mock Object 544

      Fake Object 551

Test Double Construction

      Configurable Test Double 558

      Hard-Coded Test Double 568

Test-Specific Subclass 579

Test Double

Also known as

Imposter

How can we verify logic independently when code it depends on is unusable?How can we avoid Slow Tests?

We replace a component on which the SUT depends with a "test-specific equivalent."

image

Sometimes it is just plain hard to test the SUT because it depends on other components that cannot be used in the test environment. Such ...

Get xUnit Test Patterns: Refactoring Test Code now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.