Test Double
A stand-in for a real dependency during a test — and the ways a stand-in can lie.
A test double replaces a real dependency during a test. The taxonomy, from Gerard Meszaros, distinguishes stubs (return canned answers), mocks (assert on how they were called), fakes (working but simplified implementations), and spies (record calls for later inspection).
The unifying risk is that a double can be internally inconsistent in ways the real thing is not. The clearest example: a fake data store whose create operation returns a record that its find operation cannot see. Every individual response is plausible; together they describe an impossible world. Code under test then behaves reasonably and produces nonsense — an agent that verifies its own write, sees nothing, and writes again. The test recorded something, but not what it was measuring. See Evaluation Harness.
The rule that avoids most of this: make the double a small consistent model rather than a set of independent canned answers. A ten-line store where create, find, count, and update agree is usually less work than a pile of stubs, and it cannot lie about its own state.
The second risk is that a double drifts from the real interface, so the tests pass and production fails. Contract tests, shared type definitions, and preferring real implementations wherever they are cheap enough all reduce it.
See also4
Hand-picked in the note itself — the neighbours worth reading next.
Test Fixture
The prepared data or state a test runs against.
Testing & Verification12 connections
Record and Replay Testing
Capturing a real interaction once and replaying it deterministically in later test runs.
Agents & Language Models12 connections
Unit Test
A fast, isolated test of one unit of behaviour with its collaborators replaced.
Testing & Verification11 connections
Vacuous Truth
A statement that holds only because its subject set is empty — a green result that measured nothing.
Method25 connections
Related4
Nearby in the graph rather than deliberately chosen. Looser, sometimes surprising.
Linked from6
Notes elsewhere in the wiki that reach for this one.
- Evaluation HarnessAgents & Language Models
A repeatable test suite for model behaviour, since prompts and tool descriptions cannot be type-checked.
- Headless BrowserTesting & Verification
A real browser driven programmatically without a visible window.
- Integration TestTesting & Verification
A test exercising several components together, through real interfaces rather than doubles.
- Record and Replay TestingAgents & Language Models
Capturing a real interaction once and replaying it deterministically in later test runs.
- Test FixtureTesting & Verification
The prepared data or state a test runs against.
- Unit TestTesting & Verification
A fast, isolated test of one unit of behaviour with its collaborators replaced.