missed branch coverage with instanceof checks

1,244 views
Skip to first unread message

Tim Webster

unread,
Dec 11, 2013, 2:19:54 PM12/11/13
to jac...@googlegroups.com
Hi,

I can't work out why Jacoco is reporting missed branch coverage in one of my tests.  There are a bunch of instanceof checks, but for a couple of them it's saying that a branch was missed.  The tests are definitely covering those bits of the code.  A screenshot is attached.

Any ideas?

Thanks.




missed_branches_test.jpg

Marc R. Hoffmann

unread,
Dec 11, 2013, 2:54:47 PM12/11/13
to jac...@googlegroups.com
Hi Tim,

is the red block fully exected? If it aborts somewhere in the middle due
to a exception JaCoCo can not mark it as executed.

Cheers,
-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.


Tim Webster

unread,
Dec 11, 2013, 3:10:30 PM12/11/13
to jacoco
that may be it..compareNodes() is recursive, but it throws the exception on the second iteration, so the code does make it through once...would that do it?

Thanks,

Tim


On Wed, Dec 11, 2013 at 7:54 PM, Marc R. Hoffmann <hoff...@mountainminds.com> wrote:
Hi Tim,

is the red block fully exected? If it aborts somewhere in the middle due to a exception JaCoCo can not mark it as executed.

Cheers,
-marc



On 11.12.13 20:19, Tim Webster wrote:
Hi,

I can't work out why Jacoco is reporting missed branch coverage in one of my tests.  There are a bunch of instanceof checks, but for a couple of them it's saying that a branch was missed.  The tests are definitely covering those bits of the code.  A screenshot is attached.

Any ideas?

Thanks.




--
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.

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+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.



--
Check out my wine blog: http://timswineblog.blogspot.com/

Marc R. Hoffmann

unread,
Dec 11, 2013, 3:17:46 PM12/11/13
to jac...@googlegroups.com
Hi Tim,

the block has to return normally at least once (no matter in what recursion). Blocks which are aborted somewhere in the middle with implict exceptions (no explicit throws statement) will not be marked as covered.

Cheers,
-marc


On 11.12.13 21:10, Tim Webster wrote:
that may be it..compareNodes() is recursive, but it throws the exception on the second iteration, so the code does make it through once...would that do it?

Thanks,

Tim
On Wed, Dec 11, 2013 at 7:54 PM, Marc R. Hoffmann <hoff...@mountainminds.com> wrote:
Hi Tim,

is the red block fully exected? If it aborts somewhere in the middle due to a exception JaCoCo can not mark it as executed.

Cheers,
-marc



On 11.12.13 20:19, Tim Webster wrote:
Hi,

I can't work out why Jacoco is reporting missed branch coverage in one of my tests.  There are a bunch of instanceof checks, but for a couple of them it's saying that a branch was missed.  The tests are definitely covering those bits of the code.  A screenshot is attached.

Any ideas?

Thanks.




--
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.


--
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.



--
Check out my wine blog: http://timswineblog.blogspot.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.

Tim Webster

unread,
Dec 11, 2013, 3:40:13 PM12/11/13
to jacoco
OK, that sorts out the red block....why do you think the the yellow one is missing branch coverage?  The tests cover both the explicit exception and also with not throwing the exception...

Marc R. Hoffmann

unread,
Dec 11, 2013, 4:05:45 PM12/11/13
to jac...@googlegroups.com
What yellow line? Maybe you send a new screenshot with your new coverage.

-marc


On 11.12.13 21:40, Tim Webster wrote:

Tim Webster

unread,
Dec 12, 2013, 4:30:03 AM12/12/13
to jacoco
On line 125 (attached new screenshot), it says 1 of 2 branches missed


--
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.
missed_branches_test.jpg
Reply all
Reply to author
Forward
This conversation is locked
You cannot reply and perform actions on locked conversations.
0 new messages