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 anal ...
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 practical disciplines (includin ...
,
programmer A computer programmer, sometimes referred to as a software developer, a software engineer, a programmer or a coder, is a person who creates computer programs — often for larger computer software. A programmer is someone who writes/creates ...
s employ a technique called automated unit testing to reduce the likelihood of
bugs Bugs may refer to: * Plural of bug Arts, entertainment and media Fictional characters * Bugs Bunny, a character * Bugs Meany, a character in the ''Encyclopedia Brown'' books Films * ''Bugs'' (2003 film), a science-fiction-horror film * ''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 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 Test(s), testing, or TEST may refer to: * Test (assessment), an educational assessment intended to measure the respondents' knowledge or other abilities Arts and entertainment * ''Test'' (2013 film), an American film * ''Test'' (2014 film), ...
— 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 Dummy may refer to: Dolls * Mannequin, a model of the human body * Dummy (ventriloquism) * Crash test dummy People * Dummy (nickname), any of several people with the nickname * Dummy, the Witch of Sible Hedingham (c. 1788–1863), one of the ...
— 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 t ...
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 provided ...
systems 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 ligh ...
,
software developer Software development is the process of conceiving, specifying, designing, programming, documenting, testing, and bug fixing involved in creating and maintaining applications, frameworks, or other software components. Software development inv ...
s 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 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 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 definitio ...
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 *
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 wi ...
*
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 ...
*
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 a ...


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