Jump to content

Test stub

From Wikipedia, the free encyclopedia

This is an old revision of this page, as edited by Aamir09061993 (talk | contribs) at 05:39, 13 October 2016 (Example). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

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 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. FULL ANSWER Gather all the material your instructor has provided during the semester. This includes notes, PowerPoint presentations, assignments, handouts and old exams. Go through the material either by yourself or with a study group. Make photocopies of the old tests you have taken, and white out the responses. You can use these photocopies as practice exams and retake them until you ace each one. If you are missing some questions, go back to the sections in your notes or textbook that cover the concepts. Once you are confident that you understand, retake the practice exams. Organize your notes, and look for any missing information from the lectures. Once you are certain that you have all the notes, go through them, and underline key concepts. Prepare your own practice test, and retake it until you are confident that you have mastered the material. Revisit your old assignments. You can also turn to the chapter tests in your textbook and retake them until you are fully comfortable with every question. Find other textbooks that cover the same material, and complete the exercises. Other textbooks often offer different explanations for the same problems. You might find their explanations more helpful.

See also

References

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