Reporting Test Results

Reporting Tests

Once a test case or test suite has been run, the results can be reported in a variety of formats. If the appropriate format is not already available, a custom reporter can be created to output the results as required.

In basic terms, reporting the test results is a case of:

  1. Defining an BaseReporter object variable
  2. Instantiating an BaseReporter sub-class object
  3. Calling the BaseReporter's "Report" method, passing in the Test runner.

For example (using the Text reporter):

 ROUTINE-LEVEL ON ERROR UNDO, THROW.

 USING OEUnit.Runners.OEUnitRunner.
 USING OEUnit.Automation.BaseReporter.
 USING OEUnit.Automation.TextReporter.

 /* Create an instance of your test case or suite */
 DEFINE VARIABLE suite AS SimpleSuite NO-UNDO.
 suite = NEW SimpleSuite().

 /* Create an instance of the runner */
 DEFINE VARIABLE runner AS OEUnitRunner NO-UNDO.
 runner = NEW OEUnitRunner().

 /* Create an instance of the reporter */
 DEFINE VARIABLE reporter AS BaseReporter NO-UNDO.
 reporter = NEW TextReporter("report.txt").

 /* Run your test case or suite */
 runner:RunTest(suite).

 /* Display the results */
 MESSAGE runner:Results:ToString() VIEW-AS ALERT-BOX.

 /* Report the results */
 reporter:Report(runner).

 /* Delete the test and runner */
 FINALLY:
   DELETE OBJECT reporter NO-ERROR.
   DELETE OBJECT suite NO-ERROR.
   DELETE OBJECT runner NO-ERROR.
 END FINALLY.

Available Reporters

CSV Reporter

Description

Outputs the results into a CSV based format

Constructor Parameters

Parameter Name Data Type Description
fName CHARACTER Path and File name where the output will be saved

JUnit Reporter

Description

Outputs the results into an XML file which is compatible with JUnit output.

Constructor Parameters

Parameter Name Data Type Description
fName CHARACTER Path and File name where the output will be saved

SureFire Reporter

Description

Outputs the results into an XML file which is compatible with SureFire output.

Constructor Parameters

Parameter Name Data Type Description
outputDirectoryName CHARACTER Directory where the output files will be saved

Text Reporter

Description

Outputs the results into a text file, formatted by the ToString() method of the TestResult class.

Constructor Parameters

Parameter Name Data Type Description
fName CHARACTER Path and File name where the output will be saved