JUnit XML format

You can export code review result data to a file in JUnit XML format.
You can download the JUnit XML schema from the article Apache Ant JUnit XML Schema. The mapping of the result data to the JUnit XML format is shown in Table 1.
Table 1. Mapping of result data to the JUnit schema
Type of result JUnit XML format element Attributes:
Analysis history:

The analysis history contains all the results from a code analysis scan.

<testsuites>
  • Child elements: <testsuite>
  • Attributes:
    • id: The ID of the scan.
    • name: The label of the scan.
    • tests: The total number of rules that were applied.
    • failures: The total number of rule violations.
    • time The time that was required to process all the rules.
  • Text: None
Analysis provider:

The analysis provider contains all results from a major grouping of rules, such as COBOL Code Review or PL/I Code Review.

<testsuite>
  • Child elements: <testcase>
  • Attributes
    • id: The ID of the provider.
    • name: The label of the provider.
    • tests: The number of rules in the provider that were applied.
    • failures: The number of rule violations in the provider.
    • time The time that was required to process the rules in the provider.
  • Text: None.
Analysis category:

The analysis category contains all the results from a subgroup such as Performance or Program Structures.

None. None. However, the analysis category is listed in the text that follows the <failure> element.
Analysis rule:

The analysis rule contains a summary of the result information for a single rule.

<testcase>
  • Child elements: <failure>
  • Attributes
    • id: The ID of the rule.
    • name: The label of the rule.
    • time The time that was required to process all the applications of this rule.
  • Text: None.
Analysis result:

An analysis result contains the result information for a single rule violation.

<failure>
  • Child elements: None.
  • Attributes
    • message: The source code file, the line number, and the rule that is violated.
    • type: The severity of the rule.
  • Text:
    • The text of the rule and the severity.
    • The analysis provider and the analysis category.
    • The source code file.
    • The line number
An example of result data in the JUnit XML format is shown in Figure 1.
Figure 1. Result data in JUnit XML format
<?xml version="1.0" encoding="UTF-8" ?> 
   <testsuites id="20140612_170519" name="New_configuration (14/06/12 17:05:19)" tests="225" failures="1262" time="0.001">
      <testsuite id="codereview.cobol.analysisProvider" name="COBOL Code Review" tests="45" failures="17" time="0.001">
         <testcase id="codereview.cobol.rules.ProgramIdRule" name="Use a program name that matches the source file name" time="0.001">
            <failure message="PROGRAM.cbl:2 Use a program name that matches the source file name" type="WARNING">
WARNING: Use a program name that matches the source file name
Category: COBOL Code Review – Naming Conventions
File: /project/PROGRAM.cbl
Line: 2
      </failure>
    </testcase>
  </testsuite>
</testsuites>

Feedback