Handling global variables with stubs

Component Testing for Ada

You can enable stubs to manipulate global variables in your test. For example, you can use this method to test a system input function that sets a value to a global variable.

In the stub declaration, declare an alias for the global variable in a procedure or function, as in the following examples:


# with toto;

#      procedure pr1(x:integer)[alias1:in out va];

# function return_false(param: in boolean) [alias1:in out va,alias2:in out toto.a] return BOOLEAN;



To use the global variable, specify the behavior of the global variable as in the following examples:

STUB tostub.pr1(5)[(3,6)]


STUB return_false 1=>(FALSE)[alias1=>(8,0),alias2=>((1,3),(4,5))] TRUE

STUB return_false 2=>(TRUE)[(0,10),((1,3),(7,9))] TRUE


Related Topics

Testing variablesDefining stubsDeclaring global variables for testing