-
Notifications
You must be signed in to change notification settings - Fork 0
TestDouble
A test double is an Object or Value that is controlled by TestCode and interacts with a TestSubject. Usually, the test double is specially crafted to reveal some specific characteristic or behavior of the TestSubject. See "New Thoughts on Test Doubles" for more.
The traditional hierarchy of test doubles includes the following classifications:
To which I'd add
which have been largely ignored in the literature due to OOCentrism.
Of these, TestValues, Fakes, and Dummies see the most use in my code; I occasionally use Spies when MessageBasedVerification is appropriate.
A Mock is a Spy that performs its own assertions instead of providing an interface to inspect the messages it received; while this is perhaps theoretically interesting as a technique for doing pure MessageBasedVerification without reliance on StateBasedVerification, in practice it's simply a way of adding coupling to TestCode for no real benefit.