Could I immediately reset coverage history?

131 views
Skip to first unread message

Roger Hsu

unread,
Jun 10, 2023, 5:42:17 AM6/10/23
to JaCoCo and EclEmma Users
Hello everyone, I am a newbie to Jacoco. Currently I want to use Jacoco to dynamically track all the methods and classes that are called when performing some tasks.
However, Jacoco does not provide a direct reset command, which means that the output of the dump command will contain a lot of useless information, is there any way to clear the coverage history directly?

I built a REST API application for this, first, it connects to Jacoco Agent, when I request a certain endpoint of the REST application, it starts logging all the coverage information (as it is), then, I visit another endpoint , will stop logging and export coverage information.

The problem is that I can't guarantee that no code will be executed when I start recording coverage information. So I need to manually remove the interference.

Any suggestions?

Marc Hoffmann

unread,
Jun 10, 2023, 3:41:47 PM6/10/23
to JaCoCo and EclEmma Users
Hi Roger,

our APIs support resetting coverage data. Depending on how you integrate with JaCoCo the relevant APIs are:

Runtime API (in process) / JMX


Also note that the dump() method in the same interface has an boolean parameter to control whether execution data should be reset after the dump.

Remote Protocol


With the reset parameter set tu true this command will trigger a reset.


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/72c25eb6-9067-4af1-bce6-fa4242d0a579n%40googlegroups.com.

Roger Hsu

unread,
Jun 11, 2023, 12:52:38 AM6/11/23
to jac...@googlegroups.com
Hi Marc,
Thanks for your answer, I am connecting to jacoco through port 6300 (TCP mode), refer to the example of https://www.jacoco.org/jacoco/trunk/doc/examples/java/ExecutionDataClient.java
It provides writer.visitDumpCommand method, use for downloading data, but there is no way to call IAgent.
Not sure if I could call IAgent in remote control.

Regards,
Roger

Marc Hoffmann <hoff...@mountainminds.com> 于2023年6月11日周日 03:41写道:
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/w4H0FidDjt4/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/4BBC44E1-2080-4747-AC17-C0FCC5C92BFE%40mountainminds.com.

Marc Hoffmann

unread,
Jun 11, 2023, 11:15:55 AM6/11/23
to JaCoCo and EclEmma Users
Hi Roger,

as I wrote in my answer you can set the “reset" parameter to true:


Regards,
-marc




Roger Hsu

unread,
Jun 12, 2023, 9:57:01 AM6/12/23
to JaCoCo and EclEmma Users
Thanks! It did solve my problem.
Reply all
Reply to author
Forward
0 new messages