jacoco exec not generating when output is tcpserver where as it creating when ouput as file

69 views
Skip to first unread message

raviteja y

unread,
Oct 5, 2020, 12:22:52 PM10/5/20
to JaCoCo and EclEmma Users
Hi there,

I am trying to created jaococ code coverage while running the application on my local host. For that in my jvm configuration I made changes like below and start the application. But jacoco.exec is not creating. But with same command and if I give output=file it's generating jacoco.exec file. what's the reason it's not creating when output=tcpserver. Can some one one pl help me?

-javaagent:<pathtojacoco>/org.jacoco.agent-0.8.5-runtime.jar=port=6300,destfile=<pathtojacocoexec>/target/jacoco-ft.exec,output=tcpserver

Appreciate your help!


Marc Hoffmann

unread,
Oct 5, 2020, 12:26:28 PM10/5/20
to JaCoCo and EclEmma Users
Hi,

because with the parameter “output” you define the agent outputs coverage data. If you specify “file” a file ist written. If you specify “tcpserver” the agent opens a TCP port where the data can be collected from.


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/628f8f93-2bab-4826-8705-8651d5a8fb00n%40googlegroups.com.

Evgeny Mandrikov

unread,
Oct 5, 2020, 12:26:37 PM10/5/20
to JaCoCo and EclEmma Users
Please read the documentation at https://www.jacoco.org/jacoco/trunk/doc/agent.html
which states the following about the "output" parameter

Output method to use for writing coverage data. Valid options are:
file: At VM termination execution data is written to the file specified in the destfile attribute.
tcpserver: The agent listens for incoming connections on the TCP port specified by the address and port attribute. Execution data is written to this TCP connection.

Which in my opinion perfectly explains why file is not created in case of "output=tcpserver".

raviteja y

unread,
Oct 5, 2020, 12:31:27 PM10/5/20
to JaCoCo and EclEmma Users
Hi Marc,

Thanks for your reply. If I want to see what data is collected at tcp port how can I check it?

Regards,
Ravi

Marc Hoffmann

unread,
Oct 5, 2020, 12:32:51 PM10/5/20
to JaCoCo and EclEmma Users
You need a client to “dump” the data. There is a Ant task, a Maven goal and a command line version. See documentation.


raviteja y

unread,
Oct 5, 2020, 12:47:31 PM10/5/20
to JaCoCo and EclEmma Users
Hi Marc,

Thanks for the insight. I tried in my functional tests pom file something like below. Still I don't see jacoco exec generating. Do I need to add anything else here?

<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.3</version>
<configuration>
<address>Ipaddress</address>
<destFile>/target/jacoco-ft.exec</destFile>
<port>6300</port>
<reset>false</reset>
<append>true</append>
</configuration>
<executions>
<execution>
<phase>post-integration-test</phase>
<goals>
<goal>dump</goal>
</goals>
</execution>
</executions>

raviteja y

unread,
Oct 5, 2020, 1:12:33 PM10/5/20
to JaCoCo and EclEmma Users
Hi Marc,

If I try like below by adding preparing agent in function test pom I am able to see jacoco.exec but it's showing 0% as coverage report. Pl check and let me know what I am doing wrong here


<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.3</version>
<configuration>
<address>IP Address of mac</address>

<destFile>/target/jacoco-ft.exec</destFile>
<port>6300</port>
<reset>false</reset>
<append>true</append>
</configuration>
<executions>
<execution>
<id>jacoco-initialize</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>

<execution>
<phase>post-integration-test</phase>
<goals>
<goal>dump</goal>
</goals>
</execution>
</executions>

raviteja y

unread,
Oct 5, 2020, 1:44:02 PM10/5/20
to JaCoCo and EclEmma Users
Hi Marc,

sorry for multiple messages. I am in this state now. Now jacoco.exec is generating . But when I am trying to dump coverage it's saying operation timed out. Can u pl take a look and let me know why it's timing out

[INFO] --- jacoco-maven-plugin:0.8.3:dump (default) @ func-tests ---
[INFO] Connecting to /IpAddress:6300
[INFO] Operation timed out (Connection timed out)
[INFO] Connecting to /IpAddress:6300

This is the functional test pom which I have currently

<plugin>
      <groupId>org.jacoco</groupId>
      <artifactId>jacoco-maven-plugin</artifactId>
      <version>0.8.3</version>
      <configuration>
          <address>IPAddress</address>
          <destFile>/target/jacoco-ft.exec</destFile>
          <port>6300</port>
          <reset>false</reset>
          <append>true</append>
      </configuration>
      <executions>
          <execution>
              <id>jacoco-initialize</id>
              <goals>
                  <goal>prepare-agent</goal>
              </goals>
          </execution>                
          <execution>
              <phase>post-integration-test</phase>
              <goals>
                  <goal>dump</goal>
              </goals>
          </execution>
      </executions>
</plugin>

raviteja y

unread,
Oct 5, 2020, 6:02:33 PM10/5/20
to JaCoCo and EclEmma Users
Hi Marc,

I am able to generate code coverage. Thanks for your help
Reply all
Reply to author
Forward
0 new messages