Stub Simulation
Component Testing for Ada
Stub simulation is based on the idea that subroutines to be simulated are replaced with other subroutines generated in the test driver. These simulated subroutines are often referred to as stubs.
Stubs use the same interface as the simulated subroutines, only the body of the subroutine is replaced.
Stubs have the following roles:
-
Check in and in out parameters against the simulated subroutine. If there is a mismatch, the values are stored.
-
Assign out and in out parameters from the simulated procedure
-
Return a value for a simulated function
To generate stubs, the Test Script Compiler needs to know the specification of the compilation units that are to be simulated.
Passing parameters by pointer can lead to problems of ambiguity regarding the data actually passed to the function. For example, a parameter that is described in a prototype by int *x can be passed in the following way:
int *x as input ==> f(x)
int x as output or input/output ==> f(&x)
int x[10] as input ==> f(x)
int x[10] as output or input/output ==> f(x)
Therefore, to define a stub, you must specify the following information:
-
The data type in the calling function
-
The method of passing the data
Example
An example project called Stub Ada is available from the Examples section of the Start page. This example demonstrates the use of stubs in Component Testing for Ada. See Example projects for more information.
Related Topics
Defining stubs | Using Stubs | Ada Syntax Extensions | Advanced Stubs (Ada) | Example projects