In automated unit testing, it may be necessary to use objects
or procedures that look and behave like their release-intended
counterparts, but are actually simplified versions that reduce
the complexity and facilitate testing.
(Wikipedia)
Doppelgängers?
In fiction and folklore, a doppelgänger is a look-alike or double
of a living person, sometimes portrayed as a paranormal phenomenon
[…]
(Wikipedia)
Dummies
Dummies are used when a parameter is needed for the tested method but without
actually needing to use the parameter
Kevin? You’re boring…
Franck? Please show some code!
✔ Can be as simple as `nullptr`
✔ Reduce the amount of collaborators in tests
✘ Not enforcing anything
✘ Code under test has to cope with dummies
Stubs
Stubs are used for providing the tested code with indirect input
Kevin? Still here? really??
Franck? The stage is your!
✔ Fosters simple readable tests
✔ Can be done with mocking frameworks
✘ No clue on how results are obtained
✘ Might push to write extra classes
Mocks
Mocks are used for verifying indirect output of the tested code
Kevin? *yawn*
Go Franck! Go!
✔ Better test isolation
✔ Verify protocols between objects
✘ More verbose test code
✘ Makes refactoring harder
Fakes
Fakes are used as a simpler implementation of a system (e.g. in-memory database)