Jacoco coverage reports comparison

2,240 views
Skip to first unread message

moko...@gmail.com

unread,
Dec 18, 2013, 4:14:02 AM12/18/13
to jac...@googlegroups.com
Morning,

Im in need of a way to compare 2 different coverage reports on the unit test coverage aspect. The task is to fail a jenkins job if unit test coverage in 1 report is lower than in the other. Im not using any jenkins-jacoco plugins only jacoco and sonar. Currenctly im stuck on the idea of how to get an overall coverage from a exec/csv/html or xml in the way that it can be auto compared with the other one. Fresh ideas are welcome.

Mirko Friedenhagen

unread,
Dec 18, 2013, 7:53:35 AM12/18/13
to jac...@googlegroups.com

Hello,

what do you want to compare? The check goal is not sufficient for your needs? Should both reports be created at the same time? From the same sources? Should the overall (line, branch) coverage be compared or per file/package?

Regards
Mirko
--
Sent from my mobile

On Dec 18, 2013 10:14 AM, <moko...@gmail.com> wrote:
Morning,

Im in need of a way to compare 2 different coverage reports on the unit test coverage aspect. The task is to fail a jenkins job if unit test coverage in 1 report is lower than in the other. Im not using any jenkins-jacoco plugins only jacoco and sonar. Currenctly im stuck on the idea of how to get an overall coverage from a exec/csv/html or xml in the way that it can be auto compared with the other one. Fresh ideas are welcome.

--
You received this message because you are subscribed to the Google Groups "JaCoCo and EclEmma Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jacoco+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

moko...@gmail.com

unread,
Dec 18, 2013, 9:38:05 AM12/18/13
to jac...@googlegroups.com, moko...@gmail.com
Hey,

I want to compare unit test coverage percentage. The point is to check if coverage percentage decreased from the last time we run coverage check on the same project, so 1 number is stored somewhere in a file. In the meantime i managed to figure out what to do, the only problem now is how to get the percentage from the report-html file, xpath seems to strugle.

Marc Hoffmann

unread,
Dec 18, 2013, 10:00:11 AM12/18/13
to jac...@googlegroups.com
Hi,

you can easily retrieve the total coverage figures e.g. with xpath from
the report xml file. The top level node contains the total figures:

<counter type="INSTRUCTION" missed="594" covered="18368"/>
<counter type="BRANCH" missed="50" covered="1266"/>
<counter type="LINE" missed="154" covered="4373"/>
<counter type="COMPLEXITY" missed="105" covered="1778"/>
<counter type="METHOD" missed="57" covered="1109"/>
<counter type="CLASS" missed="7" covered="199"/>

Coverage percentage can be easily calculated:

covered / (missed + covered)

Cheers,
-marc

moko...@gmail.com

unread,
Dec 19, 2013, 3:38:43 AM12/19/13
to jac...@googlegroups.com
Hey,

the probleam is ant-xpath fails because the report.xml has
<!DOCTYPE report PUBLIC "-//JACOCO//DTD Report 1.0//EN" "report.dtd">
line in it, without doctype line it wortks perfectly, im using andariel-1.2.3 for xpath.

Marc R. Hoffmann

unread,
Dec 19, 2013, 10:17:37 AM12/19/13
to jac...@googlegroups.com
Hi,

simply copy the DTD file next to the xml report. The DTD is part of the
JaCoCo distribution or can ben downloaded here:

http://www.eclemma.org/jacoco/trunk/coverage/report.dtd

Cheers,
-marc

Mirko Friedenhagen

unread,
Dec 19, 2013, 10:57:43 AM12/19/13
to jac...@googlegroups.com

Marc,

maybe we should just add the complete URL as reference, then it is my understanding that XML processors pick up the DTD automatically.

Regards
Mirko
--
Sent from my mobile

--
You received this message because you are subscribed to the Google Groups "JaCoCo and EclEmma Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jacoco+unsubscribe@googlegroups.com.

Marc R. Hoffmann

unread,
Dec 19, 2013, 8:04:38 PM12/19/13
to jac...@googlegroups.com
Hi Mirko,

I don't like picking DTDs from internet URLs due to two reasons

1) As a user you get builds wich only work with internet connectivity.
2) As a provider you might end up with heavy load from scripted clients. That's why e.g. w3c.org blocks most public DTD/Schema URLs.

Cheers,
-marc
To unsubscribe from this group and stop receiving emails from it, send an email to jacoco+un...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.
--
You received this message because you are subscribed to the Google Groups "JaCoCo and EclEmma Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jacoco+un...@googlegroups.com.

Mirko Friedenhagen

unread,
Dec 20, 2013, 2:04:04 AM12/20/13
to jacoc...@googlegroups.com

Marc,

I understand and agree with your statements. On the other side anyone using Maven has to have an internet connection now and then. Using a catalog file does help to work with a local copy for DTD. Two solutions:

1. Deploy the DTD as additional artifact to Maven Central and reference the repo1 location.

2. What about copying the DTD automatically next to the XML output?

Googling for DTDs is IMO no good solution either :-)

I have switched reply-to to the developers list as not every user might be interested in this discussion.

Regards
Mirko
--
Sent from my mobile

moko...@gmail.com

unread,
Dec 23, 2013, 7:32:47 AM12/23/13
to jac...@googlegroups.com, jacoc...@googlegroups.com
Thanks for the replies , got it working.

That aside, is there a way to handle classes with the same name besides excluding them ?

Marc R. Hoffmann

unread,
Dec 23, 2013, 11:01:56 AM12/23/13
to jac...@googlegroups.com
Yes, simply put the different versions of your classes in different groups.

Best regards,
-marc

anich...@gmail.com

unread,
May 26, 2015, 3:01:02 AM5/26/15
to jac...@googlegroups.com
Hi All,
I want to generate comparison report of two versions of Jacoco reports side by side.And I have used https://github.com/mariamr/Jacoco-Comparison-Tool tool to generate reports, however I was not able to generate reports and while generating reports exception was thrown. Following is the link to this issue -https://github.com/mariamr/Jacoco-Comparison-Tool/issues/1.
Please help me to resolve this issue.
Thanks in advance.

Evgeny Mandrikov

unread,
May 26, 2015, 3:56:18 PM5/26/15
to jac...@googlegroups.com, anich...@gmail.com
Hi,

In future please do not post the same questions in multiple threads.

Thanks.

chathu...@gmail.com

unread,
Nov 24, 2015, 2:13:02 AM11/24/15
to JaCoCo and EclEmma Users, jacoc...@googlegroups.com
how to deploy DTD as additional artifact to Maven Central and reference the repo1 location?
Reply all
Reply to author
Forward
This conversation is locked
You cannot reply and perform actions on locked conversations.
0 new messages