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 also11
Test Fixture
The prepared data or state a test runs against.
Testing & Verification16 connections
Record and Replay Testing
Capturing a real interaction once and replaying it deterministically in later test runs.
Agents & Language Models14 connections
Integration Test
A test exercising several components together, through real interfaces rather than doubles.
Testing & Verification17 connections
Fingerprint
A hash over everything that determined a result, used to detect when the result has gone stale.
Agents & Language Models12 connections
Unit Test
A fast, isolated test of one unit of behavior with its collaborators replaced.
Testing & Verification25 connections
Vacuous Truth
A statement that holds only because its subject set is empty — a green result that measured nothing.
Method26 connections
Nondeterminism
The property that identical inputs may produce different outputs, and what it costs to test around.
Agents & Language Models24 connections
Large Language Model
A neural network trained to predict text, used as a general-purpose instruction-following system.
Agents & Language Models38 connections
Service Virtualization
Replacing a real external service with a simulated one that speaks the same protocol over the network, so tests can run without the real dependency and can reproduce its failures on demand.
Testing & Verification15 connections
Fake Clock
Replacing the real clock in tests with one the test controls, so time-dependent code can be checked at midnight, across DST, or after an hour of retries without waiting.
Testing & Verification9 connections
Dependency Injection
Passing a component the things it depends on instead of letting it build them itself, which decouples code and makes it easy to substitute fakes in tests.
Testing & Verification6 connections
Linked from14
- Contract TestingTesting & Verification
Verifying that a service and its consumer agree on an interface's shape, without either side needing the other running to test against.
- Dependency InjectionTesting & Verification
Passing a component the things it depends on instead of letting it build them itself, which decouples code and makes it easy to substitute fakes in tests.
- End-to-End TestTesting & Verification
A test that drives the whole running system the way a user would, from the interface down through every real dependency, buying the most confidence at the highest cost.
- Evaluation HarnessAgents & Language Models
A repeatable test suite for model behavior, since prompts and tool descriptions cannot be type-checked.
- Fake ClockTesting & Verification
Replacing the real clock in tests with one the test controls, so time-dependent code can be checked at midnight, across DST, or after an hour of retries without waiting.
- 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 ReplayTesting & Verification
Capturing real network responses once and replaying them in later test runs, which makes tests fast and deterministic but lets the recordings drift from the real service.
- Record and Replay TestingAgents & Language Models
Capturing a real interaction once and replaying it deterministically in later test runs.
- Responsive BreakpointDesign & Interface
A viewport width at which a layout changes, and the assumptions that come with it.
- Service VirtualizationTesting & Verification
Replacing a real external service with a simulated one that speaks the same protocol over the network, so tests can run without the real dependency and can reproduce its failures on demand.
- Test FixtureTesting & Verification
The prepared data or state a test runs against.
- Test IsolationTesting & Verification
The property that each test passes or fails on its own, regardless of which other tests run, in what order, or in parallel.
- Unit TestTesting & Verification
A fast, isolated test of one unit of behavior with its collaborators replaced.