How to interpret jacoco.xml file?

I am using the JACOCO tool in a Maven project. It creates an XML code file "jacoco.xml" . Since I'm going to parse this xml, I need to know the value of some attributes in the XML file. xml contains the following elements:

<sourcefile name="Ops.java"> <line nr="3" mi="0" ci="3" mb="0" cb="0"/> <line nr="5" mi="0" ci="4" mb="0" cb="0"/> <line nr="11" mi="0" ci="5" mb="2" cb="2"/> <line nr="12" mi="0" ci="2" mb="0" cb="0"/> <line nr="14" mi="8" ci="0" mb="0" cb="0"/> <line nr="15" mi="2" ci="0" mb="0" cb="0"/> <counter type="INSTRUCTION" missed="10" covered="14"/> <counter type="BRANCH" missed="2" covered="2"/> <counter type="LINE" missed="2" covered="4"/> <counter type="COMPLEXITY" missed="2" covered="3"/> <counter type="METHOD" missed="0" covered="3"/> <counter type="CLASS" missed="0" covered="1"/> </sourcefile> 

the variable "nr" apparently means the line number. What are the values โ€‹โ€‹of the variables "mi", "ci", "mb" and "cb" ?

And here is the code coverage shown in the generated html output.

html generated output

+8
xml parsing code-coverage jacoco
source share
2 answers

mi = missed instructions (statements) ci = covered instructions (statements) mb = missed branches cb = covered branches

  • When mb or cb greater than 0, the string is a branch.
  • When mb and cb are 0 , the string is an expression.
  • cb / (mb+cb) (line 11) is a 2/4 partial hit (hence yellow)
  • If there is no branch and mi == 0 , the line falls (then green in line 5)

Thanks!

Bonus: Download these reports at Codecov https://github.com/codecov/example-java

+14
source share

You can get all definitions in report.xml from report.dtd .

For your case, this is explained below:

 <!-- representation of a source file --> <!ELEMENT sourcefile (line*, counter*)> <!-- local source file name --> <!ATTLIST sourcefile name CDATA #REQUIRED> <!-- representation of a source line --> <!ELEMENT line EMPTY> <!-- line number --> <!ATTLIST line nr CDATA #REQUIRED> <!-- number of missed instructions --> <!ATTLIST line mi CDATA #IMPLIED> <!-- number of covered instructions --> <!ATTLIST line ci CDATA #IMPLIED> <!-- number of missed branches --> <!ATTLIST line mb CDATA #IMPLIED> <!-- number of covered branches --> <!ATTLIST line cb CDATA #IMPLIED> 
0
source share

All Articles