CxxTester uses an interpreter which enables a comfortable working with testscripts and generated resultfiles. The syntax of a testscript looks like a simple subset of the C++ language.

 

There are only four keywords (see example below and in DetailView):

  • resultfile
  • deletefile
  • verify
  • extern

A testscript is a collection of one or several testcases. Every testcase is introduced with the identifier of the method or function which should be called. In addition the testcase defines all necessary input parameters and the expected results which should be verified for correctness. All result values without corresponding verify value are simply logged.

As in C++ the parameters and verification data can be elementary or structured. The datatypes of the parameters are not explained with an additional declaration but recognized in the moment of initialisation.

The verifications are expressed with the help of the C++ operators

  • = =
  • !=
  • >
  • <
  • >=
  • <=

It is possible to define global variables in order to provide constant values across different testcases. Every testscript must define at least one outputfile where the testresults are stored.

The text below is a complete testscript. Probably it will never be used in practise, because it is oversized to write a testscript for a standard divide function, but it shows most of the syntax features discussed before. The elementary description of the details and usage of CxxTester can be found in Samples.

 

deletefile "out.txt" // delete result of previous test

resultfile "out.txt" // define name of resultfile

 

// global variables

{

    param = 5          // param recognized as int

}

 

// this is the first testcase

divide

{

    p1 = (param)     // p1 recognized as int

    p2 = 4                 // p2 recognized as int

    verify:                // verify section starts here

    result == 1.25   // result recognized as double

}

 

// second testcase

divide

{

    p1 = (param)

    p2 = 3

    verify:                // note:

    result > 1.66665 // it’s more secure to use < and >

         result < 1.66667 // operators for double verification

}