Unstable code coverage results

140 views
Skip to first unread message

Vincent Massol

unread,
Feb 1, 2013, 10:13:36 AM2/1/13
to jac...@googlegroups.com

Hi Guys,

Thanks for Jacoco, it's a great tool. I've started using it but I'm having some troubles. Frequently I get different results when running it several times in a row. I'm using it from the Maven plugin and with the check mojo. I'm setting a coverage threshold in the build and making it fail when the cod coverage is below that value (using http://www.eclemma.org/jacoco/trunk/doc/check-mojo.html).

I'm using "instruction coverage".

For example I just got:

[INFO] --- jacoco-maven-plugin:0.6.1.201212231917:check (jacoco-check) @ xwiki-commons-component-default ---
[WARNING] Insufficient code coverage for INSTRUCTION: 71.76% < 71.79%

I'm wondering what could make jacoco record different results when executed several times on the same machine with the same environment/build?

How should I go about finding more about this issue?

Thanks a lot
-Vincent

Marc Hoffmann

unread,
Feb 1, 2013, 10:23:46 AM2/1/13
to jac...@googlegroups.com
I recommend to compare two HTML coverage reports and drill them down
for the differences.

Best regards,
-marc
> --
> 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
> [1].
>
>
>
> Links:
> ------
> [1] https://groups.google.com/groups/opt_out

Vincent Massol

unread,
Feb 3, 2013, 5:30:43 AM2/3/13
to jac...@googlegroups.com
Thanks Marc,

Indeed I know understand how this can happen. FTR here's the code resulting in this:

        for (Map.Entry<RoleHint< ? >, ComponentEntry< ? >> entry : this.componentEntries.entrySet()) {
            if (entry.getValue().instance == component) {
                key = entry.getKey();
                oldDescriptor = entry.getValue().descriptor;
                break;
            }
        }

This code will not take the same path at each run. this.componentEntries is a ConcurrentHashMap and calling entrySet will not return a set with a defined order. This the "if" will sometimes match the first entry and thus break outside of the "for" loop and sometimes not, thus resulting either in full branch coverage for the "if" or not...

Thanks
-Vincent
Reply all
Reply to author
Forward
This conversation is locked
You cannot reply and perform actions on locked conversations.
0 new messages