简体   繁体   English

如何解读jacoco.xml文件?

[英]how to interpret the jacoco.xml file?

I am using the JACOCO tool in Maven project. 我在Maven项目中使用JACOCO工具。 It creates code coverage XML file "jacoco.xml" . 它创建代码覆盖XML文件“jacoco.xml” As I'm going to parse this xml I need to know the meaning of some attributes in the xml file. 因为我要解析这个xml,我需要知道xml文件中某些属性的含义。 xml contains following elements: xml包含以下元素:

    <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. 变量“nr”似乎表示行号。 what are the meanings of the variables "mi", "ci", "mb" and "cb" ? 变量“mi”,“ci”,“mb”和“cb”的含义是什么?

And here is the code coverage shown in generated html output. 这是生成的html输出中显示的代码覆盖率。

生成的html输出

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

  • When mb or cb is greater then 0 the line is a branch. mbcb大于0时,该行是分支。
  • When mb and cb are 0 the line is a statement. mbcb0该行是一个语句。
  • cb / (mb+cb) (line 11) is 2/4 partial hit (hence yellow) cb / (mb+cb) (第11行)是2/4部分命中(因此是黄色)
  • When not a branch and mi == 0 the line is hit (hence green in line 5) 当不是分支并且mi == 0 ,线被击中(因此第5行为绿色)

Thank you! 谢谢!

Bonus: Upload these reports to Codecov https://github.com/codecov/example-java 奖励:将这些报告上传到Codecov https://github.com/codecov/example-java

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM