jargon

Comparison

SpyvsStub

Spy

you wrap the real thing, let it do its actual job, and record the calls so you can check them afterwards.

A double that records how it was used for later assertion, often wrapping a real implementation. Unlike a mock it does not set expectations up front — you assert after the fact, which reads more naturally and couples less. It is the middle ground between a stub that asserts nothing and a mock that asserts everything.

Full entry →

Stub

you hard-code the collaborator to return a fixed value so the code under test has something to work with.

A double that returns canned responses, providing inputs to the code under test. It has no assertions and no logic; it exists so the test can reach the code path you care about. If your test asserts on what the stub was called with, you have written a mock.

Full entry →

Related comparisons