← Graph

Diagnostic Substitutes Are Not Mock Objects

question 2 connections

Audience member pushes back that checking `http_client.posted?(content)` in a test looks exactly like a mock or a spy. Bellware agrees the behaviour is similar in spirit but insists on the architectural distinction: a mock is retrofitted transparency added to the test file after design is finished, violating the system to make it observable. A diagnostic substitute is designed-in — the production class ships a `Substitute` that exposes telemetry through the same interface, so the transparency lives with the design rather than in the test. Also covers how to handle dependencies that return data (specialise the substitute to allow setting return values — not ideal but sometimes necessary for HTTP client libraries).

answer_summary
Architecturally different: mocks retrofit transparency in the test file; diagnostic substitutes are part of the production class's own design. Similar observable effect, different design posture.
question Diagnostic Substitutes Are Not Mock Objects
about
The question asks how diagnostic substitutes differ from mocks and spies.
question Diagnostic Substitutes Are Not Mock Objects
asked_at
Audience question during the talk's Q&A.

Provenance

Read by
1 extraction