Skip to content

Fake vs stub vs mock

The four doubles in a table; the fake is the only one that behaves.

Aspect

Stub

Spy

Mock

Fake

Behaviour

Canned answer

Delegates to real

Canned + asserts

Real, simplified

Records calls

No

Yes

Yes

Depends

Fails on its own

No

No

Yes

No

Production-realistic

Low

High

Low

Medium

Maintenance cost

Low

Medium

High

High