JaCoCo Test Coverage Badges?

744 views
Skip to first unread message

andy....@gmail.com

unread,
Feb 10, 2018, 6:39:10 PM2/10/18
to JaCoCo and EclEmma Users
Hello,

I'm using JaCoCo in Maven to generate test coverage reports. It's working great! It works so well I want to put a badge in my GitHub README -- like the "build: passing" badges you see all over -- to motivate me to keep my test coverage up.

I've poked around for ways to generate a badge from JaCoCo Test Coverage data. It looks like there are plugins for Jenkins and Travis, but both of those cost a good bit of money for use on private repositories. I'm using AWS CodeBuild -- which is cheap and has been working great for me -- but has no JaCoCo badge support that I can see.

Is there a good way to build test coverage badges in JaCoCo?

If there isn't currently a good way, would the JaCoCo team be interested in a new goal in the maven plugin to generate said badges? I imagine the goal could be called "badge" (or similar) and would be designed to consume the report-aggregate output, and it would generate an SVG file reflecting total test coverage across all files.

If this sounds interesting to the team, I'd be happy to rough out an implementation for review!

Marc Hoffmann

unread,
Feb 11, 2018, 11:00:39 AM2/11/18
to jac...@googlegroups.com
Hi,

thanks for sharing this idea! If this can be easly done (e.g. with our
existing XML output facilities) it looks like a nice gimmick.

Can you please provide a example SVG how you think it should look like?

Cheers,
-marc

Marc Hoffmann

unread,
Feb 11, 2018, 3:32:50 PM2/11/18
to jac...@googlegroups.com
Hi,

I played a bit with svg badges. Would something as simple as the one
attached to the job? This would be quite simple to generate.

I wouldn't create a new goal for this. It could simply be another report
format of the existing reporting tools (Maven, Ant, Command Line).

Cheers,
-marc

On 2018-02-11 00:39, andy....@gmail.com wrote:
badge-jacoco.svg

andy....@gmail.com

unread,
Feb 11, 2018, 3:51:28 PM2/11/18
to JaCoCo and EclEmma Users
Hi Marc,

That was quick! And the badge looks great! It also makes sense that it wouldn't be a new goal, now that you've said it.

Here's a brief wish list, based on how our builds work:

* The badge should also be generated for the aggregate goal in the maven plugin
* It would be nice to have a new optional parameter with value 0-100 default 70 -- maybe called something like "passing" -- that represents the minimum passing score. If the coverage is greater than or equal to the passing score, the badge is green; otherwise, it's red, indicating more tests are needed.

Thank you for taking the idea so seriously! Please let me know if there's anything I can do to help development!

On Sunday, February 11, 2018 at 12:32:50 PM UTC-8, Marc R. Hoffmann wrote:
> Hi,
>
> I played a bit with svg badges. Would something as simple as the one
> attached to the job? This would be quite simple to generate.
>
> I wouldn't create a new goal for this. It could simply be another report
> format of the existing reporting tools (Maven, Ant, Command Line).
>
> Cheers,
> -marc
>

Marc Hoffmann

unread,
Feb 11, 2018, 4:42:58 PM2/11/18
to jac...@googlegroups.com
Hi Andy,

> If the coverage is greater than or equal to the passing score, the
> badge is green;
> otherwise, it's red, indicating more tests are needed.

I'm a bit scared about such customization requirements especially when
it comes to UI. They tend to draw a lot of attention, cause many
discussions and keep us from working on the core. That's why we
typically refuse them.

I would propose to use a linear gradient from red to green depending on
statement coverage. Would that work for you?

Cheers,
-marc

Mirko Friedenhagen

unread,
Feb 11, 2018, 4:47:10 PM2/11/18
to jac...@googlegroups.com
Hello,

another caveat: which metric to use for this. I would go for complexity, as it is the most valuable IMO.

Best 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.
To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/ffaa673c2496a59945520dc6a8097138%40mountainminds.com.
For more options, visit https://groups.google.com/d/optout.

Marc Hoffmann

unread,
Feb 11, 2018, 4:57:09 PM2/11/18
to jac...@googlegroups.com

Hi Mirko,

I also consider this as the most valuable metric. But I'm afraid this is rarely used. Therefore I'm tempted to show instruction coverage.

But missed complexity would make another nice badge: "Missing: xxx tests" ;)

Cheers,
-marc

To unsubscribe from this group and stop receiving emails from it, send an email to jacoco+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/CAK8jvqyF2jrCUu20SYSqr9_ginSn5XkPG0xw0MTqn104G1fF4g%40mail.gmail.com.

Andy Boothe

unread,
Feb 12, 2018, 1:56:57 AM2/12/18
to jac...@googlegroups.com
Marc,

All I’m really looking for is a clear difference in appearance between a “passing” coverage score and a “failing” one so you can tell at a glance how your build is doing.

I’m not a designer, and therefore in no way particular about the details. There are some good examples of what I have in mind online, probably pulled from a very similar place to where you pulled your badge! Would it be helpful if I tracked an example or two down?

Re: scores and metrics, maybe it makes sense to use the same rule approach as the check goal? Have the badge colored based on a single limit? It already exists and users are familiar. 



To unsubscribe from this group and stop receiving emails from it, send an email to jacoco+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/ffaa673c2496a59945520dc6a8097138%40mountainminds.com.
For more options, visit https://groups.google.com/d/optout.

 

--
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.
--
You received this message because you are subscribed to a topic in the Google Groups "JaCoCo and EclEmma Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jacoco/TImJb1UsfS8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jacoco+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/331081e8fa3b44ba5297ffd6145b8c46%40mountainminds.com.
Reply all
Reply to author
Forward
This conversation is locked
You cannot reply and perform actions on locked conversations.
0 new messages