jacoco java8 and lambdas/Runnables

1,234 views
Skip to first unread message

olio...@gmail.com

unread,
Aug 20, 2014, 5:37:43 AM8/20/14
to jac...@googlegroups.com
Hi all,

does anyone else also experienced this? I am using jacoco 0.7.1 and my project has a lot of lambdas and Runnables. And even if I am sure those were executed during the test the report does not show any of the lines in them as executed. This is true for the whole project, non of the lines of the lambdas or Runnables were reported as covered. (It is true for the jenkins or for the jacoco reports)

like:


[COVERED ] trigger.callLater(() -> {
[NO COVER] any statement here;
[NO COVER] any statement here;
[NO COVER] any statement here;
);

[COVERED ] trigger.callLater(new Runnable() {
[NO COVER] public void run() {
[NO COVER] any statement here;
[NO COVER] }
);

Is it expected or an issue? Or something went wrong with my project (compiler, jacoco version, etc)

Thanks for any hints

Cheers

Tamas

olio...@gmail.com

unread,
Aug 20, 2014, 5:51:39 AM8/20/14
to jac...@googlegroups.com, olio...@gmail.com
I have to correct myself. the jacoco report (called from ant) works on Runnables and does not on lambdas. The jenkins report (different thing) does not work on both.

olio...@gmail.com

unread,
Aug 20, 2014, 5:56:19 AM8/20/14
to jac...@googlegroups.com, olio...@gmail.com
another note:
it seems jacoco ignores the lines of the lambda from the method level report. So a method like:

void doit(Param p){
p.reset();
p.call(() -> {
log.debug("logit");
});
}

will be reported as 100% on 3 lines (p.reset(), p.cal..., last '}')

Marc Hoffmann

unread,
Aug 20, 2014, 6:26:51 AM8/20/14
to jac...@googlegroups.com
Hi,

can you please

- provide a running reproducer (compilable Java file) and
- describe the expected behavior for this example

Note that I can investigate the native JaCoCo report only. The Jenkins
report is a different implementation which is not maintained here at the
JaCoCo project.

Thanks,
-marc

olio...@gmail.com

unread,
Aug 20, 2014, 7:28:48 AM8/20/14
to jac...@googlegroups.com
Hi,

thanks for your response. Yes you can ignore the jenkins report, probably some of it comes from the original jacoco issue, but not related here.

Here is the sample project to reproduce it:
https://github.com/kalidasya/jacoco-issue

just run mvn clean verify and check the: target/site/jacoco/org.jacoco.issue.lambda/Caller.java.html report. the Runnable part is covered but the lambda isnt. Also note it has 100% coverage, but the line number is not correct (see: target/site/jacoco/org.jacoco.issue.lambda/index.source.html).

But maybe I misunderstand something related to lambdas, but I expect the same coverage as in the Runnable case.

Thanks for helping

Cheers

Tamas

Marc R. Hoffmann

unread,
Aug 20, 2014, 2:49:08 PM8/20/14
to jac...@googlegroups.com
Hi Tama,

many thanks for reporting this! I was able to reproduce this and opened
an issue for it:

https://github.com/jacoco/jacoco/issues/232

Cheers,
-marc

Tamás Kende

unread,
Aug 20, 2014, 3:51:47 PM8/20/14
to jac...@googlegroups.com
You are welcome! 


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

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