CHECK STUB

C++ Test Script Language

Syntax

CHECK STUB <stub name> { <stub item>}

CHECK STUB <stub name>;

Location

TEST CASE

Description

The CHECK STUB instruction checks that a stub is called at least once during the TEST CASE execution.

If a block is provided, it specifies that <stub item> should be executed instead of the stub's "..." zone. If no block is provided, the execution of the stub's "..." does nothing.

If the stub is not called, an error is generated. Error handling behavior is specified with the ON ERROR keyword.

Note: The use of stubs requires instrumentation of the source code under test.

<stub name> is a valid stub identifier.

<stub item> may be one the following entities:

  1. CHECK

    COMMENT

    PRINT

    Native statement

Only one CHECK STUB may refer to the same STUB in a TEST CASE.

Note   The CHECK STUB statement may be used before the corresponding STUB is defined.

Example

 

STUB ModifyCell : int IntArray::Modify (int Cell)

REQUIRE (Cell != 128)

{

       #int Nb = random(10000);

       ... // this part is completed by the code of CHECK STUB

       this.array[Cell] = Nb;

       #return (Nb);

}

TEST SUITE A {

       TEST CASE 1 {

             CHECK STUB ModifyCell;

             #IntArray ia;

             #InitializeArray (ia); // this function calls IntArray::ModifyCell

             // ia is filled with random numbers

       }

       TEST CASE 2 {

             CHECK STUB ModifyCell {

                    #Nb = 0;

             }

             #IntArray ia;

             #InitializeArray (ia); // this function calls IntArray::ModifyCell

             // ia is filled with 0

       }

}

RUN { A; }