Home > User Support > CoverageMaster winAMS FAQ

CoverageMaster winAMS FAQ

Stub Functions

002_04: How can I create and manage stub functions?

Question:

How can I create and manage stub functions? And how can I replace the original sub-function with a stub function?

Answer:

[Stub Function Types]

The are two types of stub functions, Global Stub Functions and Local Stub Functions.

One global stub function can be created per sub-function and it can be used by all functions.

In case both func1() and func2() call the sub-function sub(), global stub function AMSTB_sub() can be created and used by both functions. Separate features to test each function cannot be created when using a global stub function.

A local stub function of a sub-function can be created and used for each test function separately. In case both func1() and func2() call the sub-function sub(),

AMSTB_func1_sub() can be created and used for the func1() test, and
AMSTB_func2_sub() can be created and used for the func2() test separately.

By using local stub functions separate features to test each function can be implemented. However, the number of stub functions and the code size will be larger when using local stub functions compared to global stub functions, so global stub functions are recommended for regular use.

[How to replace a sub-function with a stub function]

There are two methods for replacing sub-functions with stub functions

1. The "Replace" checkbox in the Stub Settings screen

A sub-function can be replaced with a stub function by checking the "Replace" checkbox in the Stub Settings screen. Unchecking the "Replace" checkbox will cause the original sub-function to be executed.

This method is very simple, however all calls to the sub-function for all tests in the project will be replaced by the stub function.

2. CSV File Stub Setting

Using the CSV File Stub Setting, stub replacement is written into the test CSV file. Instead of using the "Replace" checkbox to replace all sub-function calls with stub functions, the user can set only certain test CSV files to use stub functions. Many users choose to use this method as it allows more control of stub function replacement.


Related Technical Tips Search

Other technical tips in GAIO's web site can be searched for using the links below.

Search key word link: Stub Creation
Technical Tips Google Search

 


Information Links