vesii
vesii

Reputation: 3128

Understanding the JaCoCo coverage XML report

I have managed to create a JaCoCo XML coverage report. In the report I get:

<class
name="PATH"
 sourcefilename="DeleteUtility.java">
  <method name="&lt;init&gt;"
  desc="(Lcom/commons/treenode/PathNode;)V"
   line="20">
    <counter type="INSTRUCTION" missed="17" covered="0" />

    <counter type="LINE" missed="6" covered="0" />

    <counter type="COMPLEXITY" missed="1" covered="0" />

    <counter type="METHOD" missed="1" covered="0" />
  </method>
...

I have a few questions about the format:

  1. Sometimes the method name is &lt;init&gt;" or "&lt;clinit&gt;". I guess it's <init> and <clinit>. What does those methods mean?
  2. What does desc mean?
  3. What does COMPLEXITY mean?
  4. Is INSTRUCTION the amount of keywords in the method?

Upvotes: 2

Views: 2725

Answers (2)

ocean553
ocean553

Reputation: 1

<init> is the contructor the a class DeleteUtility

<clinit> is the code coverage of static variables (e.g. static Logger logger = Logger.getLogger(LoggingExample.class.getName()). In the HTML report it is stated as static{...}

desc contains the parameters types and return-type of the method. In your example the only parameter would be PathNode and the return type would be void (V).

There are some special cases for desc:

  • Classes: starts with a leading L (e.g. Ljava/lang/String)
  • Array as parameter: starts with a leading [ (e.g. [Ljava/lang/String)
  • primitive types: are only represented with one special char
    • byte: B
    • short: S
    • int: I
    • long: J
    • float: F
    • double: D
    • boolean: Z
    • char: C
    • void: V

A method like the following:

public int foo(int i, byte[] b, String s, ABC a, long l) {..}

would have the following desc:

desc="(I[BLjava/lang/String;Lorg/foo/ABC;J)I"

Upvotes: 0

0xh3xa
0xh3xa

Reputation: 4857

Instruction smallest unit JaCoCo counts are single Java byte code instructions. Instruction coverage provides information about the amount of code that has been executed or missed.

Complexity calculates cyclomatic complexity for each non-abstract method and summarizes complexity for classes, packages, and groups.

Method Each non-abstract method contains at least one instruction. A method is considered as executed when at least one instruction has been executed

Line For all class files that have been compiled with debug information, coverage information for individual lines can be calculated

Branch The total number of branches (if and switch statements) in a method that can be executed or missed.

see the documentation in Jacoco https://www.eclemma.org/jacoco/trunk/doc/counters.html

Upvotes: 1

Related Questions