Difficults with merging jacoco.exec

1,340 views
Skip to first unread message

ggr...@gmail.com

unread,
Jul 20, 2018, 10:23:45 AM7/20/18
to JaCoCo and EclEmma Users
In our project some tests placed in different module than tested service.
mvn+jacoco+sonar+TFS

configs used:

1) default config ("prepare-agent" + "report") reports 40% coverage

2) report-aggregate reports 55% of coverage.

in #1 config some services has 0%(incorrect) coverage and non-zero(correct) coverage in #2.

3) As is SonarCube uses *.exec files as coverage sources, i tried "merge" goal

it produces merged file which reports 0% coverage totally.


How to make correct merged coverage report?

versions:

jacoco-maven-plugin:0.7.7........
SonarCube:7.1 (build 11001)
java:8

ggr...@gmail.com

unread,
Jul 20, 2018, 10:48:16 AM7/20/18
to JaCoCo and EclEmma Users
and jacoco-maven-plugin:0.8.1

Evgeny Mandrikov

unread,
Jul 20, 2018, 5:08:13 PM7/20/18
to JaCoCo and EclEmma Users

ggr...@gmail.com

unread,
Jul 23, 2018, 5:53:03 AM7/23/18
to JaCoCo and EclEmma Users
As i can understand, jacoco.exec and report contains different data.
report-aggregate and merge do not change any data, but result is different.

how to check it?

суббота, 21 июля 2018 г., 0:08:13 UTC+3 пользователь Evgeny Mandrikov написал:

Evgeny Mandrikov

unread,
Jul 23, 2018, 7:00:35 AM7/23/18
to JaCoCo and EclEmma Users


On Monday, July 23, 2018 at 11:53:03 AM UTC+2, ggr...@gmail.com wrote:
As i can understand, jacoco.exec and report contains different data.

Report - is a result of analysis of exec-file and classes.
If some of analyzed classes wasn't executed at all, then they won't be presented in exec-file, but can be presented as uncovered in report.
And vise-versa - exec-file might contain information about more classes than you selected for analysis for report.

 
report-aggregate and merge do not change any data, but result is different. 

What is different? What is compared to what?

And why do you expect result to be the same?

To understand difference between "report" and "report-aggregate" consider following example:
module A contains classes A1 and A2 and test that covers class A1, so execution of this test will result in A-exec-file containing information about class A1.
module B contains test that covers class A2, so execution of this test will result in B-exec-file containing information about class A2.
report for module A (analysis of A-exec-file with classes A1 and A2) will show class A1 as covered and class A2 as uncovered.
report-aggregate ( analysis of A-exec-file and B-exec-file with classes A1 and A2 ) will show both A1 and A2 as covered.

If you merge A-exec-file and B-exec-file, then on the same example:
analysis of merged-exec-file with classes A1 and A2, will show both as covered.


how to check it? 

Look at your tests to know what they execute, look at report to know what it shows as executed, compare.

ggr...@gmail.com

unread,
Jul 23, 2018, 8:57:21 AM7/23/18
to JaCoCo and EclEmma Users
Got it!

/parent/pom.xml
<properties>
<sonar.jacoco.reportPaths>${maven.multiModuleProjectDirectory}/jacoco-aggregate-report/target/aggregate.exec</sonar.jacoco.reportPaths>

ggr...@gmail.com

unread,
Jul 23, 2018, 9:07:07 AM7/23/18
to JaCoCo and EclEmma Users

ggr...@gmail.com

unread,
Jul 23, 2018, 10:14:25 AM7/23/18
to JaCoCo and EclEmma Users
> What is different? What is compared to what?

They coverage are same or too close.

> And why do you expect result to be the same?

*.exec & report is just two presentations of coverage. they coverage must be
equals because they use one coverage source.

> To understand difference between "report" and "report-aggregate" consider following example:

report & report-aggregate works fine, but sonar do not use them.

> > how to check it? 
>
> Look at your tests to know what they execute, look at report to know what it shows as executed, compare.

all good now.

sonar analyzing only target/*.exec files for each module by default.
just take aggregate.exec for sonar and all works fine.

I sure that must be in Sonar Docs, but it will be good to place scenarion in jacoco docs too.
Reply all
Reply to author
Forward
This conversation is locked
You cannot reply and perform actions on locked conversations.
0 new messages