Test double
In computer programming and computer science, programmers employ a technique called automated unit testing to reduce the likelihood of bugs occurring in the software. Frequently, the final release software consists of a complex set of objects or procedures interacting together to create the final result. 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. A test double is a generic (meta) term used for these objects or procedures. Types of test doubles
Gerard Meszaros identified several terms for what he calls, "Test Doubles." Using his vocabulary, there are at least five types of Test Doubles:

 Test stub — used for providing the tested code with "indirect input". Mock object — used for verifying "indirect output" of the tested code, by first defining the expectations before the tested code is executed. Test spy — used for verifying "indirect output" of the tested code, by asserting the expectations afterwards, without having defined the expectations before the tested code is executed. It helps in recording information about the indirect object created. Fake object — used as a simpler implementation, e.g. using an in-memory database in the tests instead of doing real database access. Dummy object — used when a parameter is needed for the tested method but without actually needing to use the parameter. For both manual and automated black box testing of service oriented architecture systems or microservices, software developers and testers use test doubles that communicate with the system under test over a network protocol. These test doubles are called different names depending on the tool vendor. A commonly used term is service virtualization. Other names used include API simulation, API mock, HTTP stub, HTTP mock, over the wire test double
. Another form of test double is the verified fake, a fake object whose behavior has been verified to match that of the real object using a set of tests that run against both the verified fake and the real implementation. While there is no open standard for test double and the various types, there is momentum for continued use of these terms in this manner. Martin Fowler used these terms in his article, Mocks Aren't Stubs referring to Meszaros' book. Microsoft also used the same terms and definitions in an article titled, Exploring The Continuum Of Test Doubles. See also
 Mock object
 Software testing
 Service virtualization
 Comparison of API simulation tools
 List of unit testing frameworks
 Object-oriented programming
 Test-driven development

References

External links
Gerard Meszaros:
Test Double
Test Double Patterns
Mocks, Fakes, Stubs and Dummies
Martin Fowler:
TestDouble, 17 January 2006
Open source:
 ELF Spy - Fakes and Spies in C++
 FakeIt - Mocks, Fakes and Spies in C++
 Google Mock - Mocking in C++
 jMock - Test Driven Development with Mocks
 Mockito - Mocking Framework for Java
 unittest.mock - Mocking with Python

Software testing
Software design patterns
Software development process