liveBook · Manning

Dummy test double

As explained in Unit Testing Principles, Practices, and Patterns

A test double supplied only to satisfy an interface or parameter requirement without participating meaningfully in execution.

A dummy is a simple, hardcoded test double—such as a null value or made-up string—passed to the system under test only to satisfy a method signature. It does not participate in producing the final outcome. section 5.1 section 5.5

Use the classification to avoid confusing a dummy with more active substitutes:

  • Treat dummies, stubs, spies, mocks, and fakes as test-double variations; distinguish them by their role in the test. section 5.1
  • Use a stub when the dependency must provide configured input, and a mock when the test examines an interaction that changes state. section 5.1
  • Do not assert a dummy’s interaction: it contributes neither input nor an observable side effect. section 5.5

Parameter-only dependency

A test can pass a null value or made-up string when a required parameter exists only because the SUT’s method signature requires it. If the value affects the result, it is no longer functioning as a dummy. section 5.1

Figure 5.1. All variations of test doubles can be categorized into two types: mocks and stubs.

Use the classification diagram to place dummies alongside stubs, spies, mocks, and fakes, then reduce the practical distinction to mocks versus stubs. section 5.1

How Unit Testing Principles, Practices, and Patterns covers it

How deep it goes
Defines dummies and contrasts them with stubs, mocks, spies, and fakes, stopping short of a dedicated implementation procedure.
Examples
Uses null values and made-up strings as parameter-only dummy values.
What it assumes
Assumes familiarity with systems under test, collaborators, method signatures, and basic test doubles.
What you can do after
Evaluate whether a dependency merely satisfies a signature or must provide input or support an asserted interaction.
How it connects
Connects dummies with test doubles, stubs, mocks, spies, fakes, observable behavior, and implementation details.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Unit Testing Principles, Practices, and Patterns. The section links point to the parts of the book it draws on.