Skip to content

How it works

The dummy is instantiated with no state, passed once, and forgotten; if the code under test interacts with it, the test fails at the interaction, not at the assertion.

graph LR
  T[Test] --> S[System under test]
  T --> D[Dummy]
  S -.->|if calls| D
  D -.->|no behaviour| X[Failure or noop]
  style D fill:#FFF3E0
  style X fill:#FFEBEE

The pattern in practice. Minimal interface: the dummy implements the interface with methods that throw "not implemented" or return null — whichever the framework treats as a failure. Single use: created inside the test, not shared, not reused. Visible intent: the variable name (dummyAddress, unusedRepository) states what the test intends.