Jump to content

Test stub: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
Papapasan (talk | contribs)
No edit summary
Tags: Mobile edit Mobile web edit
Line 3: Line 3:
{{cquote|Test stubs provide [[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>}}
{{cquote|Test stubs provide [[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>}}


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.
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==
==Example==

Revision as of 18:53, 26 May 2015

In computer science, test stubs are programs that simulate the behaviors of software components (or modules) that a module undergoing tests depends on.

Test stubs provide canned answers to calls made during the test, usually not responding at all to anything outside what's programmed in for the test.[1]

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 returns 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

References

  1. ^ Fowler, Martin (2007), Mocks Aren't Stubs (Online)