C test script structure

The C test script language allows you to structure tests to:

  • Describe several test cases in a single test script,

  • Select a subset of test cases according to different Target Deployment Port criteria.

Test script filenames must contain only plain alphanumerical characters.

Basic structure

A typical C Component Testing .ptu test script looks like this:

HEADER add, 1, 1

<variable declarations for the test script>

BEGIN

SERVICE add

<local variable declarations for the service>

TEST 1

FAMILY nominal

ELEMENT

VAR variable1, INIT=0, EV=0

VAR variable2, INIT=0, EV=0

#<call to the procedure under test>

END ELEMENT

END TEST

END SERVICE

All instructions in a test script have the following characteristics:

  • All statements begin with a keyword.

  • Statements are not case sensitive (except when C expressions are used).

  • Statements start at the beginning of a line and end at the end of a line. You can, however, write an instruction over several lines using the ampersand (&) continuation character at the beginning of additional lines. In this case, the ampersand must be the very first character on that line; no spaces or tabs should precede it.

  • Statements must be shorter than 2048 characters, although this limit may be lower on some platforms.

Structure statements

The following statements allow you to describe the structure of a test.

  • HEADER: For documentation purposes, specifies the name and version number of the module being tested, as well as the version number of the tested source file. This information is displayed in the test report.

  • BEGIN: Marks the beginning of the generation of the actual test program.

  • SERVICE: Contains the test cases related to a given service. A service usually refers to a procedure or function. Each service has a unique name (in this case add). A SERVICE block terminates with the instruction END SERVICE.

  • TEST: Each test case has a number or identifier that is unique within the block SERVICE. The test case is terminated by the instruction END TEST.

  • FAMILY: Qualifies the test case to which it is attached. The qualification is free (in this case nominal). A list of qualifications can be specified (for example: family, nominal, structure) in the Tester Configuration dialog box.

  • ELEMENT: Describes a test phase in the current test case. The phase is terminated by the instruction END ELEMENT. The different phases of the same test case cannot be dissociated after the tests are run, unlike the test cases introduced by the instruction NEXT_TEST. However, the test phases introduced by the instruction ELEMENT are included in the loops created by the instruction LOOP.

The three-level structure of the test scripts has been deliberately kept simple. This structure allows:

  • A clear and structured presentation of the test script and report

  • Tests to be run selectively on the basis of the service name, the test number, or the test family.

Related Topics

C test script keywords | C test script language | Writing a Test Script