Test Double
   HOME

TheInfoList



OR:

In
computer programming Computer programming is the process of performing a particular computation (or more generally, accomplishing a specific computing result), usually by designing and building an executable computer program. Programming involves tasks such as ana ...
and
computer science Computer science is the study of computation, automation, and information. Computer science spans theoretical disciplines (such as algorithms, theory of computation, information theory, and automation) to Applied science, practical discipli ...
, 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 Object may refer to: General meanings * Object (philosophy), a thing, being, or concept ** Object (abstract), an object which does not exist at any particular time or place ** Physical object, an identifiable collection of matter * Goal, an ...
or
procedures Procedure may refer to: * Medical procedure * Instructions or recipes, a set of commands that show how to achieve some result, such as to prepare or make something * Procedure (business), specifying parts of a business process * Standard opera ...
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 In advanced polymorphism computer science, test stubs are programs that simulate the behaviours of software components (or modules) that a module undergoing tests depends on. Test stubs provide canned answers to calls made during the test, usuall ...
— used for providing the tested code with "indirect input". *
Mock object In object-oriented programming, mock objects are simulated objects that mimic the behaviour of real objects in controlled ways, most often as part of a software testing initiative. A programmer typically creates a mock object to test the behaviou ...
— 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 In object-oriented programming, mock objects are simulated objects that mimic the behaviour of real objects in controlled ways, most often as part of a software testing initiative. A programmer typically creates a mock object to test the behaviou ...
— 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 Black-box testing is a method of software testing that examines the functionality of an application without peering into its internal structures or workings. This method of test can be applied virtually to every level of software testing: unit, ...
of
service oriented architecture In software engineering, service-oriented architecture (SOA) is an architectural style that focuses on discrete services instead of a monolithic design. By consequence, it is also applied in the field of software design where services are provide ...
systems A system is a group of interacting or interrelated elements that act according to a set of rules to form a unified whole. A system, surrounded and influenced by its environment, is described by its boundaries, structure and purpose and express ...
or
microservices A microservice architecture – a variant of the service-oriented architecture structural style – is an architectural pattern that arranges an application as a collection of loosely-coupled, fine-grained services, communicating through lightw ...
,
software developer Software development is the process of conceiving, specifying, designing, Computer programming, programming, software documentation, documenting, software testing, testing, and Software bugs, bug fixing involved in creating and maintaining applic ...
s and testers use test doubles that communicate with the
system under test System under test (SUT) refers to a system that is being tested for correct operation. According to ISTQB it is the test object. From a Unit Testing perspective, the SUT represents all of the classes in a test that are not predefined pieces of co ...
over a network protocol. These test doubles are called different names depending on the tool vendor. A commonly used term is
service virtualization Service may refer to: Activities * Administrative service, a required part of the workload of university faculty * Civil service, the body of employees of a government * Community service, volunteer service for the benefit of a community or a p ...
. 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 In object-oriented programming, mock objects are simulated objects that mimic the behaviour of real objects in controlled ways, most often as part of a software testing initiative. A programmer typically creates a mock object to test the behaviou ...
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 An open standard is a standard that is openly accessible and usable by anyone. It is also a prerequisite to use open license, non-discrimination and extensibility. Typically, anybody can participate in the development. There is no single definition ...
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''.{{cite web , title=''Exploring The Continuum Of Test Doubles'' , url=http://msdn.microsoft.com/en-us/magazine/cc163358.aspx , last=Seemann , first=Mark , year=2007 , accessdate=2010-12-29


See also

*
Mock object In object-oriented programming, mock objects are simulated objects that mimic the behaviour of real objects in controlled ways, most often as part of a software testing initiative. A programmer typically creates a mock object to test the behaviou ...
*
Software testing Software testing is the act of examining the artifacts and the behavior of the software under test by validation and verification. Software testing can also provide an objective, independent view of the software to allow the business to apprecia ...
*
Service virtualization Service may refer to: Activities * Administrative service, a required part of the workload of university faculty * Civil service, the body of employees of a government * Community service, volunteer service for the benefit of a community or a p ...
*
Comparison of API simulation tools The tools listed here support emulating or simulating APIs and software systems. They are also called API mocking tools, service virtualization tools, over the wire test doubles and tools for stubbing and mocking HTTP(S) and other protocols. They ...
*
List of unit testing frameworks This article is a list of tables of code-driven unit testing frameworks for various programming languages. Some, but not all, of these are based on xUnit. Columns (classification) * Name: This column contains the name of the framework and wil ...
*
Object-oriented programming Object-oriented programming (OOP) is a programming paradigm based on the concept of "objects", which can contain data and code. The data is in the form of fields (often known as attributes or ''properties''), and the code is in the form of pr ...
*
Test-driven development Test-driven development (TDD) is a software development process relying on software requirements being converted to test cases before software is fully developed, and tracking all software development by repeatedly testing the software against al ...


References


External links

Gerard Meszaros:
Test Double
Martin Fowler:

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

- Mocking with Python Software testing Software design patterns Software development process