Test stub: Difference between revisions
Appearance
Content deleted Content added
mNo edit summary |
Stevebroshar (talk | contribs) Move general info to test double |
||
(34 intermediate revisions by 27 users not shown) | |||
Line 1: | Line 1: | ||
{{More citations needed|date=February 2021}} |
|||
In computer science, '''test stubs''' are programs which simulate the behaviors of software components (or modules) that are depended-upon modules of the module being tested. |
|||
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 which act as temporary replacement for a called module and give the same output as the actual product/software. |
|||
==Example== |
|||
Consider a computer program which queries a database to obtain the sum price total of all products stored in the database. However, the query is slow and consumes a large number of system resources. This reduces the number of test runs per day. Secondly, the tests may need to be conducted on values outside those which are currently in the database. |
|||
The method (or call) used to perform this is ''get_total()''. For testing purposes, the source code in ''get_total()'' could be temporarily replaced with a simple statement which returned a specific value. This would be a test stub. |
|||
There are several testing frameworks available and there is software that can generate '''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]] |
||
* [[Stub (distributed computing)]] |
|||
==References== |
==References== |
||
{{reflist}} |
|||
<references/> |
|||
⚫ | |||
⚫ | |||
[[Category:Software testing]] |
[[Category:Software testing]] |
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]