I am using the JACOCO tool in Maven project. It creates code coverage XML file "jacoco.xml". As I'm going to parse this xml I need to know the meaning of some attributes in the xml file. xml contains 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>
variable "nr" seems to mean line number. what are the meanings of the variables "mi", "ci", "mb" and "cb"?
And here is the code coverage shown in generated html output.
In IntelliJ Idea from the menu select Analyze > Show Coverage data . In the new window press the + button and select your . exec file. The test coverage results will appear in the editor Coverage tab.
JaCoCo reports are an essential component of Cover Reports, which provides insights about your code to help your team identify gaps in your application's coverage.
To get code coverage reports in a Maven project, we first need to set up the JaCoCo Maven plugin for that project. By integrating the JaCoCo plugin, the results of the code coverage analysis can be reviewed as an HTML report. The current version of the JaCoCo-Maven plugin can be downloaded from the MVN Repository.
Jacoco is an open source project, which can be used to check production code for test code coverage. It creates reports and integrates well with IDEs like the Eclipse IDE. Integration is also available for other IDEs and continuous integration environments.
mi = missed instructions (statements)
ci = covered instructions (statements)
mb = missed branches
cb = covered branches
mb
or cb
is greater then 0 the line is a branch.mb
and cb
are 0
the line is a statement.cb / (mb+cb)
(line 11) is 2/4
partial hit (hence yellow)mi == 0
the line is hit (hence green in line 5)Thank you!
Bonus: Upload these reports to Codecov https://github.com/codecov/example-java
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With