Test Macros

The Test Framework defines macros that you may use to create applications to run your tests.

The runTestImplementationMacro defines an application to run a single test. The beginTestFrameworkMacro, runTestMacro, endTestFrameworkMacro, and runTestResultMacro macros may be used within a main routine to create an application that can run several tests.

Applications created using these macros recognize several options: -t, -e, -n, and -o options (see below). The -test option must be specified when running the application.

Command-line options understood by the application created using the macros are shown in the following table:

-e[cho] h|g|n|d|D Set detail of diagnostic output: headline, general, normal, detail, Debug
-n numberOfRuns Run the test numberOfRuns times; default is to run test once.
-o[ptions] Pass further arguments (after the -o) to the ITest subclass.
-t[est] class Run the ITest subclass class.
-log [logfilename] Write the output into logfilename.

runTestImplementationMacro

The runTestImplementationMacro macro expands to define the entire main routine to create and run a single test. It takes the name of the test class for its parameter. The test object is created and the run function is called for the test. The main routine returns with a 0 indicating that the test succeeded; otherwise, 1 is returned.

beginTestFrameworkMacro, runTestMacro, endTestFrameworkMacro, runTestResultMacro

Use beginTestFrameworkMacro, runTestMacro, endTestFrameworkMacro, and runTestResultMacro to create an application that can run various tests instead of just one. The following table summarizes each of these macros:

beginTestFrameworkMacro Takes argc and argv for its parameters. This macro expands the code to parse the command-line arguments for options.
runTestMacro Takes the name of the test class for its parameter. This macro expands the code to create and run the text.
endTestFrameworkMacro Takes no parameters. This macro expands the code to check if a test was run and prints out an error if no test was run.
runTestResultMacro Returns a boolean indicating whether test succeeded.

To use these macros you must write your own main routine:

  1. In main routine, use beginTestFrameworkMacro with the argc/argv values.
  2. Use runTestMacro for each test class you wish to run.
  3. Use the endTestFrameworkMacro and runTestResultMacro to get the result of the test.

Only the test specified with the -t option will be run when the application executes.