Test stub: Difference between revisions
Appearance
Content deleted Content added
Minor- |
Stevebroshar (talk | contribs) Move general info to test double |
||
(31 intermediate revisions by 24 users not shown) | |||
Line 1: | Line 1: | ||
{{More citations needed|date=February 2021}} |
|||
In computer science, '''test stubs''' are programs that simulate the behaviors of software components (or modules) that a module undergoing tests depends on. |
|||
A '''test stub''' is a [[test double]] that provides static values to the software under test. |
|||
A test stub provides [[Canned_response|canned answers]] to calls made during the test, usually not responding at all to anything outside what's programmed in for the test.<ref>Fowler, Martin (2007), ''Mocks Aren't Stubs'' [http://martinfowler.com/articles/mocksArentStubs.html#TheDifferenceBetweenMocksAndStubs (Online)]</ref> |
|||
A stub may be [[source code|coded]] by hand or generated via a [[software tool|tool]]. |
|||
Test stubs are mainly used in incremental testing's top-down approach. Stubs are computer programs that act as temporary replacement for a called module and give the same output as the actual product or software. |
|||
==Example== |
|||
Consider a computer program that queries a database to obtain the sum price total of all products stored in the database. In this example, the query is slow and consumes a large number of system resources. This reduces the number of test runs per day. Secondly, tests may need include values outside those currently in the database. The method (or call) used to perform this is ''get_total()''. For testing purposes, the source code in ''get_total()'' can be temporarily replaced with a simple statement that returnes a specific value. This would be a test stub. |
|||
Several testing frameworks are available, as is software that generates '''test stubs''' based on existing source code and testing requirements. |
|||
==See also== |
==See also== |
||
* [[Mock object]] |
|||
* [[Method stub]] |
|||
* [[Software testing]] |
* [[Software testing]] |
||
* [[Test Double]] |
* [[Test Double]] |
||
Line 19: | Line 17: | ||
==External links== |
==External links== |
||
*[http://xunitpatterns.com/Test%20Stub.html |
*[http://xunitpatterns.com/Test%20Stub.html Test Stub at XUnitPatterns.com] |
||
Latest revision as of 11:56, 4 May 2024
This article needs additional citations for verification. (February 2021) |
A test stub is a test double that provides static values to the software under test.
A test stub provides canned answers to calls made during the test, usually not responding at all to anything outside what's programmed in for the test.[1]
A stub may be coded by hand or generated via a tool.
See also
[edit]References
[edit]External links
[edit]