DEFINE STUB ... END DEFINE
Ada Test Script Language
Purpose
The DEFINE STUB and END DEFINE instructions delimit a simulation block consisting of stub definition declarations written in Ada.
Syntax
DEFINE STUB <stub_name> [ <stub_dim> ]
[# <Ada statement>]
END DEFINE
where:
-
<stub_name> is the mandatory name of a simulation block.
<stub_dim> is an optional maximum number of stub calls errors that will be displayed in the report.
Description
Defining stubs in a test script is optional.
DEFINE STUB blocks must be located after the BEGIN instruction and outside any SERVICE block.
By default, all functions and procedures of the <stub_name> package are simulated. The DEFINE STUB block can also contain Ada function, procedure and assignment declarations preceded with the # character.
Using the stub definitions, the Ada Test Script Compiler generates simulation variables and functions for which the interface is identical to that of the stubbed variables and functions.
The purpose of these simulation variables and functions is to store and test input parameters, assign values to output parameters, and if necessary, return appropriate values.
Stub parameters describe both the type of item used by the calling function and the mode of passing. The mode of passing the parameter is specified by adding the following before the parameter name:
-
in for input parameters
out for output parameters
in out for input/output parameters
_no for parameters that you do not want to test
Additionally, when using the in or in out parameters, you can add an optional _nocheck parameter before the in or in out parameter (see the Example paragraph). This allows the parameters to be sent to the stub without being checked.
The parameter mode is optional. If no parameter mode is specified, the in mode is assumed by default.
A return parameter is always deemed to be an output parameter.
Global variables defined in DEFINE STUB blocks replace the real global variables.
By default, only the first 10 errors are shown in the report. Any more errors are not recorded. The number of calls should be customized if necessary by using the <stub_dim> parameter.
Example
An example of the use of stubs is available in the StubAda example project installed with the application.
Related Topics