no coverage for some line executed code

40 views
Skip to first unread message

Aaron zhang

unread,
Oct 26, 2019, 12:05:40 PM10/26/19
to JaCoCo and EclEmma Users

left is jacoco, right is idea coverage.


we can look at it, result is not different, actually, we can see that they should be covered.


more information, code line "orderOwnerValidator.validate(orderIntegratedDTO);"  throws exceptions by executing test case.


recondition:

1.  jacoco agent version 0.8.5, and 0.7.3

2. org.jacoco.report version 0.8.3

3. tcp server mode

 

屏幕快照 2019-10-26 下午11.53.55.png


Evgeny Mandrikov

unread,
Oct 26, 2019, 1:59:56 PM10/26/19
to JaCoCo and EclEmma Users
https://www.jacoco.org/jacoco/trunk/doc/faq.html

Source code lines with exceptions show no coverage. Why?

JaCoCo determines code execution with so called probes. Probes are inserted into the control flow at certain positions. Code is considered as executed when a subsequent probe has been executed. In case of exceptions such a sequence of instructions is aborted somewhere in the middle and the corresponding line of source code is not marked as covered.

Aaron zhang

unread,
Oct 28, 2019, 4:30:26 AM10/28/19
to JaCoCo and EclEmma Users
Firstly, Thank you very much!

I have the other question, why no cover for code line "object.isNull(orderIntegreatedDTO)"? is this the reason, too?  it does not throw exception. 

在 2019年10月27日星期日 UTC+8上午1:59:56,Evgeny Mandrikov写道:

Evgeny Mandrikov

unread,
Oct 28, 2019, 5:01:51 AM10/28/19
to JaCoCo and EclEmma Users

On Monday, October 28, 2019 at 9:30:26 AM UTC+1, Aaron zhang wrote:
is this the reason, too?

Yes.

Aaron zhang

unread,
Oct 28, 2019, 6:42:42 AM10/28/19
to JaCoCo and EclEmma Users
Is this a bug for jacoco? i think that should be covered for code line "object.isNull(orderIntegreatedDTO)". because:

1. the line is parallel with code line "orderOwnerValidator.validate(orderIntegratedDTO);", the line code should be executed completedly.
2. the subsequent probe of  "orderOwnerValidator.validate(orderIntegratedDTO);" should not affect code line "object.isNull(orderIntegreatedDTO)".



在 2019年10月28日星期一 UTC+8下午5:01:51,Evgeny Mandrikov写道:

Evgeny Mandrikov

unread,
Oct 28, 2019, 8:02:02 AM10/28/19
to JaCoCo and EclEmma Users
This is a known limitation - https://github.com/jacoco/jacoco/pull/321
which is not so trivial to fix as you might think,
because as explained in the ticket it requires addition of more probes,
what requires change version of exec file,
breaking compatibility for every third-party tool and library that read this file directly.

Aaron zhang

unread,
Oct 28, 2019, 8:21:01 AM10/28/19
to JaCoCo and EclEmma Users
ok, thanks!

在 2019年10月28日星期一 UTC+8下午8:02:02,Evgeny Mandrikov写道:
Reply all
Reply to author
Forward
This conversation is locked
You cannot reply and perform actions on locked conversations.
0 new messages