JaCoCo XML Output

The gcovr command can generate a JaCoCo XML output using the --jacoco and --jacoco-pretty options:

gcovr --jacoco-pretty --jacoco example_jacoco.xml

This generates an XML summary of the lines executed:

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE report SYSTEM 'https://www.jacoco.org/jacoco/trunk/coverage/report.dtd'>
<report name="GCOVR report">
  <package name="">
    <sourcefile name="example.cpp">
      <line nr="3"/>
      <line nr="5" mb="1" cb="1"/>
      <line nr="7"/>
      <line nr="11"/>
      <line nr="15"/>
      <line nr="17"/>
      <line nr="19"/>
      <counter type="LINE" missed="1" covered="6"/>
      <counter type="BRANCH" missed="1" covered="1"/>
      <counter type="METHOD" missed="0" covered="2"/>
    </sourcefile>
    <counter type="LINE" missed="1" covered="6"/>
    <counter type="BRANCH" missed="1" covered="1"/>
    <counter type="METHOD" missed="0" covered="2"/>
  </package>
  <counter type="LINE" missed="1" covered="6"/>
  <counter type="BRANCH" missed="1" covered="1"/>
  <counter type="METHOD" missed="0" covered="2"/>
</report>

This XML format is described in the JaCoCo XML DTD.

The --jacoco option generates a denser XML output, and the --jacoco-pretty option generates an indented XML output that is easier to read. Note that the XML output contains more information than the tabular summary. The tabular summary shows the percentage of covered lines, while the XML output includes branch statistics and the number of times that each line was covered. Consequently, XML output can be used to support performance optimization in the same manner that gcov does.

Added in version 7.0: The --jacoco and --jacoco-pretty.