Test Stubs - Example

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 need to be conducted on values larger than what is 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.

Read more about this topic:  Test Stubs

Famous quotes containing the word example:

    Our intellect is not the most subtle, the most powerful, the most appropriate, instrument for revealing the truth. It is life that, little by little, example by example, permits us to see that what is most important to our heart, or to our mind, is learned not by reasoning but through other agencies. Then it is that the intellect, observing their superiority, abdicates its control to them upon reasoned grounds and agrees to become their collaborator and lackey.
    Marcel Proust (1871–1922)