How do I make jacoco take into account the coverage of what is run by tests as Runtime.exec(...) or ProcessBuilder(...).start()?

34 views
Skip to first unread message

Nicos109

unread,
Nov 13, 2022, 9:22:26 AM11/13/22
to JaCoCo and EclEmma Users
Hello,

I'd like the jacoco report to take into consideraton the parts of the code covered by other jvms started with a Runtime.exec("java", "Main"). Is there a way to do this ?

Thanks
Nicolas

Marc Hoffmann

unread,
Nov 13, 2022, 10:19:23 AM11/13/22
to JaCoCo and EclEmma Users
Hi Nicolas,

if you start a new Java process and want to collect coverage for it make sure to also configure the JaCoCo agent for it. See documentation:


Regards,
-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.
To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/55950fab-fba3-41d8-b0db-dc7038af7a9dn%40googlegroups.com.

Nicolas Baumann

unread,
Nov 13, 2022, 10:41:25 AM11/13/22
to jac...@googlegroups.com
Hi,

Thanks for your reply. I managed to configure the agent for each individual execution which generates a jacoco_xxx.exec. Now I have a lot of exec files and not sure what to do with them. Also I've read on another answer of yours that jacoco needs access to the class files directly from the project. In fact my class files are not part of the project, they're generated on the fly. Is this going to work for me ? Maybe I'm better off creating a maven goal that will generate all these classes inside the project before test phase  ?

Thanks
Nicolas 

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/PAzo5-C8orc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jacoco+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/5307C34E-0E82-4BC3-9C8C-092FE52D83D5%40mountainminds.com.

Marc Hoffmann

unread,
Nov 13, 2022, 10:50:04 AM11/13/22
to JaCoCo and EclEmma Users
Hi Nicolas,

it really depends what you want to create the report for: For all executions incl. the parent process? For every execution separately?

In any case JaCoCo offers a lot of flexibility:

* Exec files: Can be written to individual files, can be merged afterwards with the merge commands. Or can be directly all written to the same file.
* Class files: You need them at the point in time when you create the report. You only need those files which should be shown.

Regards,
-marc


Reply all
Reply to author
Forward
0 new messages