Running the jacocoagent using tcpserver/file mode does not produce any coverage.

30 views
Skip to first unread message

shweta...@gmail.com

unread,
Jun 19, 2020, 1:50:36 AM6/19/20
to JaCoCo and EclEmma Users

The following steps does not generate any coverage for code that is covered by tests.

- I added the javaagent to the VM config of my service like this:

-javaagent:./lib/jacocoagent.jar=output=tcpserver,address=127.0.0.1,port=2710,includes=./target/classes/com/p/cd-poc -Dconfig=./etc/config.properties -Dlog.levels-file=./etc/log.properties


- Next I brought up the service locally and hit an endpoint and generated a report using the jacococli.jar using the following commands:

java -jar lib/jacococli.jar dump --destfile jdump.exec --address 127.0.0.1 --port 2710

java -jar lib/jacococli.jar report jdump.exec --classfiles cd-poc-1.0-SNAPSHOT.jar --xml j.xml


The generated j.xml has 0 coverage for all the methods.

I observed this behaviour even when the endpoint was hit using an integration test case. 


A little background about the code. The code is a JAVA service and the integration tests are written in Ruby.

Am I missing something here? 

Evgeny Mandrikov

unread,
Jun 19, 2020, 3:21:57 AM6/19/20
to JaCoCo and EclEmma Users
On Friday, June 19, 2020 at 7:50:36 AM UTC+2 shweta...@gmail.com wrote:

The following steps does not generate any coverage for code that is covered by tests.

- I added the javaagent to the VM config of my service like this:

-javaagent:./lib/jacocoagent.jar=output=tcpserver,address=127.0.0.1,port=2710,includes=./target/classes/com/p/cd-poc -Dconfig=./etc/config.properties -Dlog.levels-file=./etc/log.properties


Please carefully read the documentation - https://www.jacoco.org/jacoco/trunk/doc/agent.html :

includes - A list of class names that should be included in execution analysis. The list entries are separated by a colon (:) and may use wildcard characters (* and ?). Except for performance optimization or technical corner cases this option is normally not required.

whereas your "./target/classes/com/p/cd-poc" looks like a directory name.

shweta...@gmail.com

unread,
Jun 19, 2020, 1:44:17 PM6/19/20
to JaCoCo and EclEmma Users
Thanks a lot Evgeny. That was indeed the issue. Unsetting the "includes" argument made it work!
Reply all
Reply to author
Forward
0 new messages