- Source: Test double
A test double is software used in software test automation that satisfies a dependency so that the test need not depend on production code. A test double provides functionality via an interface that the software under test cannot distinguish from production code.
A programmer generally uses a test double to isolate the behavior of the consuming code from the rest of the codebase.
A test double is usually a simplified version of the production code and may include capabilities specific to testing.
Test doubles are used to build test harnesses.
Uses
A test double may be used to simplify and speed test execution.
For example, a program that uses a database server is relatively slow and consumes significant system resources – which impedes testing productivity. Also, a test case might require values outside those stored in the database.
A test double might provide a static value instead of accessing a database.
A test double may be used to test part of the system that is ready for testing even if its dependencies are not.
For example, in a system with modules Login, Home and User, suppose Login is ready for test, but the other two are not.
The consumed functions of Home and User can be implemented as test doubles so that Login can be tested.
Types
Test doubles are categorization many ways.
= General
=Although not universally accepted, Gerard Meszaros categorizes test doubles as:
Stub — provides static input
Mock — verifies output via expectations defined before the test runs (differs from Mock object)
Spy — supports setting the output of a call before a test runs and verifying input parameters after the test runs
Fake — a relatively full-function implementation that is better suited to testing than the production version; e.g. an in-memory database instead of a database server
Dummy value — a value that is required for the tested interface but for which the test case does not depend
While there is no open standard for categories, 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.
= Service
=For service oriented architecture (SOA) systems and microservices, testers use test doubles that communicate with the system under test over a network protocol. These test doubles are called by different names by the tool vendors. A commonly used term is service virtualization. Other names used include API simulation, API mock, HTTP stub, HTTP mock, over the wire test double
.
= Verified fake
=A verified fake is 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.
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
Kata Kunci Pencarian:
- Double Asteroid Redirection Test
- Double Whoopee
- MasterChef Indonesia (musim 4)
- The Tree in a Test Tube
- X (media sosial)
- ChatGPT
- Pengeboran inti
- Rantai blok
- Daftar kata serapan dari bahasa Inggris dalam bahasa Indonesia
- Beelzebub
- Test double
- Double Asteroid Redirection Test
- Blinded experiment
- Unit testing
- Test-driven development
- List of Test cricket records
- Double-disk diffusion test
- Test stub
- Triple test
- Reversal test
No More Posts Available.
No more pages to load.