← ClaudeAtlas

test-double-typelisted

Choose the right test double — stub, fake, spy, or mock. Use when deciding which test double to reach for, or when a mock is being used and the test asserts on calls rather than outcomes.
ecoma-io/touchstone · ★ 1 · Testing & QA · score 60
Install: claude install-skill ecoma-io/touchstone
# Test Double Types Base principles: [test-isolation-base](../test-isolation-base/SKILL.md) One word — "mock" — is doing duty for four different things: | Double | What it is | Reach for it | | -------- | ---------------------------------------------------------------- | ---------------------------------------------------------- | | **Stub** | canned answers, records nothing | first: most collaborators are only a source of input | | **Fake** | a real but simplified implementation, e.g. an in-memory store | when the code writes to the collaborator and reads it back | | **Spy** | a stub that also records how it was called | only when the call itself is the observable effect | | **Mock** | a spy with expected calls declared up front, failing on the rest | almost never: it asserts choreography by construction | The last two rows are last on purpose. A double that records calls invites an assertion about calls. Reach for a spy or mock by naming the outcome you could have asserted instead. If you cannot name the outcome, the call is not the behaviour — it is the mechanism. Default to a hand-written stub or fake. It satisfies only the interface at the point of use and breaks loudly when the contract moves. Per-language: [TypeScript](references/typescript.md)