Discrepancy between JaCoCo XML and SonarCloud coverage report

Currently using JaCoCo Maven Plugin (0.8.8) with Java 11 and SonarCloud. I noticed very minor discrepancy between the JaCoCo XML to the SonarCloud coverage report. I am concerned that if there is one difference there might be others.

Specifically, I noticed that a getter/setter is not shown as used/tested in SonarCloud. I am confident that the path to the XML report is correct.

<method name="getFoo" desc="()Ljava/lang/String;" line="148">
<counter type="INSTRUCTION" missed="0" covered="9"/>
<counter type="BRANCH" missed="0" covered="2"/>
<counter type="LINE" missed="0" covered="1"/>
<counter type="COMPLEXITY" missed="0" covered="2"/>
<counter type="METHOD" missed="0" covered="1"/>
</method>
<method name="setFoo" desc="(Ljava/lang/String;)V" line="152">
<counter type="INSTRUCTION" missed="0" covered="4"/>
<counter type="LINE" missed="0" covered="2"/>
<counter type="COMPLEXITY" missed="0" covered="1"/>
<counter type="METHOD" missed="0" covered="1"/>
</method>

Hi,

Welcome to the community!

Can we have a screenshot of the other half of this equation? I.e. the “not tested” getter/setter?

 
Ann

Thanks. Here are the getter/setter

public String getFoo() {
	return foo == null ? super.getFoo() : foo;
}

public void setFoo(String foo) {
	this.foo = foo;
}

Hi,

I asked for a screenshot because I was hoping to see the marginal coverage markers.

 
Ann

Screen Shot 2022-10-26 at 11.18.35 AM

I had been using a different method name for the previous illustrations to keep it generic but this is the actual names I am using throughout

Hi,

Thanks for the screenshot. One more thing, can I have the analysis log? I’d like to see the processing of the coverage report.

 
Ann

which report do you want and where would i find it?

Hi,

I’m hoping to see the analysis job log, which you’ll find in your CI.

 
Thx,
Ann

Thanks! That was the nudge I needed. The JaCoCo xml location definition was configured using a maven parameter instead of a literal relative path. Fixing this to be a relative path worked like a charm.

Thanks again for your help.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.