Examples of test doubles
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
.gitignore
README.md
pom.xml

README.md

TestDoubles

Test doubles are like stunt doubles, they take the place of the 'real' thing in test code. They are particularly useful in TDD but can also help in making existing tests quicker, more reliable and more controllable.

Dummy Object

This is a placeholder object that is passed to the SUT as an argument (or an attribute of an argument) but is never actually used.

Test Stub

This is an object that replaces a real component on which the SUT depends so that the test can control the indirect inputs of the SUT. It allows the test to force the SUT down paths it might not otherwise exercise. Some examples are hard-coded and configurable responders and saboteurs

Test Spy

A Test Spy is a more capable version of a Test Stub. It can be used to verify the indirect outputs of the SUT by giving the test a way to inspect them after exercising the SUT. An example of verifying indirect outputs.

Mock Object

This is an object that replaces a real component on which the SUT depends so that the test can verify its indirect outputs. An example of the mock