Testing Variables

Component Testing for Ada

One of the main features of Component Testing for Ada is its ability to compare initial values, expected values and actual values of variables during test execution. In the Ada Test Script Language, this is done with the VAR statement.

The VAR statement specifies both the test start-up procedure and the post-execution test for simple variables. This instruction uses three parameters:

Declare variables under test with the VAR statement, followed by the declaration keywords:

Component Testing for Ada allows you to define initial and expected values with standard Ada expressions.

All literal values, variable types, functions and most operators available in the Ada language are accepted by Component Testing for Ada.

It does not matter where the VAR instructions are located with respect to the test procedure call since the Ada code generator separates VAR instructions into two parts :

Many other forms are available that enable you to create more complex test scenarios.

Example

The following example demonstrates typical use of the VAR statement

HEADER add, 1, 1

#with add;

BEGIN

SERVICE add

 # a, b, c : integer;

 TEST 1

  FAMILY nominal

  ELEMENT

   VAR a, init = 1, ev = init

   VAR b, init = 3, ev = init

   VAR c, init = 0, ev = 4

   #c := add(a,b);

  END ELEMENT

 END TEST

END SERVICE

Related Topics

Testing intervalsTesting tolerancesReporting a variable without testingTesting expressions