Multiple stub calls

Component Testing for Ada

For a large number of calls to a stub, use the following syntax for a more compact description:

<call i> .. <call j> =>


You can describe each call to a stub by adding the specific cases before the preceding instruction, for example:

<call i> =>


<call i> .. <call j> =>


The call count starts at 1 as the following example shows:


 FAMILY nominal

 COMMENT Reading of 100 identical lines


 VAR file1, init = "file1", ev = init

 VAR file2, init = "file2", ev = init

 VAR s, init == , ev = 1

 STUB open_file 1=>("file1")3

 STUB create_file 1=>("file2")4

 STUB read_file 1..100(3,"line")1, 101=>(3,"")0

 STUB write_file 1..100=>(4,"line")1

 STUB close_file 1=>(3)1,2=>(4)1

 #s = copy_file(file1,file2);



Several Calls to a Stub

If a stub is called several times during a test, either of the following are possible:

The following example rewrites the test to use this syntax for the call to the STUB close_file:

STUB close_file (3)1

STUB close_file (4)1

No Testing of the Number of Calls of a Stub

If you don't want to test the number of calls to a stub, you can use the keyword others in place of the call number to describe the behavior of the stub for the calls to the stub not yet described.

For example, the following instruction lets you specify the first call and all the following calls without knowing the exact number:

STUB write_file 1=>(4,"line")1,others=>(4,"")1

Related Topics

Stub SimulationDefining StubsUsing StubsSizing StubsAdvanced Stubs