Do not understand branch coverage

77 views
Skip to first unread message

vi...@meenuta.net

unread,
Aug 15, 2015, 5:02:34 PM8/15/15
to JaCoCo and EclEmma Users
Hi,

I am trying to move from Cobertura to jacoco and get huge branch coverage difference. Started to investigate it and..

Can someone explain what I am missing.

I have finally block in my code and it is:
} finally {
try {
if (rs != null) {
rs.close();
}
if (st != null) {
st.close();
}
if (con != null) {
con.close();
}

} catch (SQLException ex) {
ex.printStackTrace();
}
}

And on that jacoco report thinks that

if (rs != null) { >> 0/8 branches
rs.close(); >>0/12 branches
And so on. What are these 12 branches in rs.close() sentence? And in if I can get 2 (rs is NULL or isn't NULL)

Br,

Villu

vi...@meenuta.net

unread,
Aug 16, 2015, 12:56:20 PM8/16/15
to JaCoCo and EclEmma Users, vi...@meenuta.net
Answering myself. Maybe someone avoids spending searching solution.
Key point was moving Cobertura->Jacoco, as I wanted to keep both coverage tools in work together. There were Cobertura-Instrumented classes in classpath and these were causing these problems for jacoco (most probably there was compiled into such info that was causing problems), after removing cobertura totally, I am getting similar results in Jacoco that were previously with Cobertura

Villu

Marc Hoffmann

unread,
Aug 17, 2015, 5:12:47 AM8/17/15
to jac...@googlegroups.com
Hi Villu,

thanks for this follow-up! Anyways, in the particular example provided,
you came across a known limitation: JaCoCo works on Java bytecode and
therefore reflects certain compiler artifacts. In case of finally
statements the code is actually emitted twice (once for the good case,
once for the exception path). Therefore all branches seems to double.
Please find a description here:

https://github.com/jacoco/jacoco/wiki/filtering-JAVAC.FINALLY

Future versions of JaCoCo might detect and filter such situations.

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