JaCoCo does not detect that certain instructions are run (covered) if these lead to an implicit exception. In the following example, if c() throws an exception, the result indicate no coverage for b().
public void foo() {
a();
try {
b();
c();
} catch (Throwable t) {}
}
In the following example, no coverage at all is reported, assuming c() again throws an exception.
public void bar() {
a();
b();
c();
}
Note that the last example is quite common when writing JUnit 4 tests using the "expected" keyword, as in the following example.
@Test(expected=SomeException.class)
public void testBar() {
...
}
I experimented with adding more probes inserted in front of opcodes that may thrown an (implicit) exception. With such probes more precise coverage results are obtained, at the cost of having more probes. This means a slower execution (analysis) speed, and bigger instrumented class files.
In my _preliminary_ experiments I see about 1-2% of increased coverage, if coverage of the Test classes is included in the report. This comes at the cost of about 1% more runtime when compared to the current release of JaCoCo.
I am now interested in your opinions on this. Do you think having a more precise analysis as described is worthwhile? Should the feature be in JaCoCo, or not? Should it be configurable, possibly disabled by default?
On a more technical note, it is possible to only add probes for some of the opcodes which may thrown an exception. For example, one could add probes for INVOKE opcodes (which would help with the JUnit tests, based on my experience), and not add probes for PUTFIELD and array opcodes.
Best regards,
Carsten
--
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/s6Xbj69308Y/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jacoco+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and all its topics, send an email to jacoco+un...@googlegroups.com.
--
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.
It would be interesting to see some examples of highlighted source code for both versions of JaCoCo.
> What do you think about having a separate version of JaCoCo which is more precise (and, sadly, slower)?
Speaking for the JaCoCo project we will stay with one version. We can't handle multiple versions and this will also confuse users as many users use JaCoCo in different tools.
> Can you think of a way to speed up JaCoCo while still having better coverage results?
Not sure whether this can be implemented but I'm thinking about installing exception handlers with the instrumented code since quite some time.