Collecting Executed Statements for Specific Test Method with JaCoCo

43 views
Skip to first unread message

m1k0

unread,
Aug 10, 2024, 9:58:14 AM8/10/24
to JaCoCo and EclEmma Users
Dear Team,

I hope this message finds you well. I am a newcomer to both Java and JaCoCo, and I am currently looking to collect information on all executed statements within a Java library when running a specific test method. I would like to know if it is possible to achieve this by modifying JaCoCo.

From my research, it seems that JaCoCo might not be able to target specific test methods directly. I ran the entire test class 'TestClass', using the following command:

java -javaagent:/workspace/jacocoagent.jar=destfile=/workspace/jacoco.exec -cp /workspace/project-sourceCode.jar:/workspace/build-tests/:/workspace/junit.jar junit.textui.TestRunner TestClass

However, this still does not meet my exact needs. I am concerned that inserting probes for every statement in the entire project would result in an excessively large array. I am unsure whether JaCoCo can be further customized to fulfill my requirements.

I would greatly appreciate any guidance or suggestions you could offer.

Thank you very much for your time and assistance.

Marc Hoffmann

unread,
Aug 10, 2024, 10:08:23 AM8/10/24
to JaCoCo and EclEmma Users
Hi,

not sure whether I understand you question correctly.

I am concerned that inserting probes for every statement in the entire project would result in an excessively large array.

This is the core functionality of JaCoCo. We do actually not insert probes after every instruction. Instead we insert a few probes at strategic position into the control flow so that we can infer the execution status of every instruction and branch at analysis time. You can read about this here: https://www.jacoco.org/jacoco/trunk/doc/flow.html

JaCoCo is actually used by very large projects since many years.

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/7af116ed-779e-490a-821e-d853f77ce8d3n%40googlegroups.com.

m1k0

unread,
Aug 10, 2024, 10:40:29 AM8/10/24
to JaCoCo and EclEmma Users
Thank you very much for your response. Your reply has been very helpful to me. Additionally, I have another question. Since my goal is to collect information on executed statements, I believe that I can further analyze the execution of the control flow graph to determine which statements are executed when running specific test methods. Does JaCoCo have an API that allows access to the execution details of the control flow graph? Thanks!!!
Reply all
Reply to author
Forward
0 new messages