0

I am trying to run integration tests on my java code from remote server, so whenever my tests hit my code server, jacoco records it.

I am new to jacoco, till now i have gather that there is tcp server method which doesnot require any restart.

  1. I have added below line in my /etc/profile.
export JAVA_OPTS="-javaagent:/home/vansh/jacoco/lib/jacocoagent.jar=address=*,port=57026,destfile=/home/vansh/jacoco/jacoco.exec,output=tcpserver"

2)but when i am trying to take dump using below command -

java -jar jacococli.jar dump --address localhost --port  57026 --destfile /home/vansh/jacoco/jacoco-it.exec
ERROR:

[INFO] Connecting to localhost/127.0.0.1:57026.
[WARN] Connection refused (Connection refused).
[INFO] Connecting to localhost/127.0.0.1:57026.
Exception in thread "main" java.net.ConnectException: Connection refused (Connection refused)
    at java.base/java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.base/java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:399)
    at java.base/java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:242)
    at java.base/java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:224)
    at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:403)

I checked that there is nothing run on port 57026, is my first command javaagent one is correct?

vansh madan
  • 128
  • 1
  • 1
  • 10

1 Answers1

1

I have done same thing a year ago, In my case I run a TCP_Client jar for collecting the dump with many ways(periodically/with and without resetting previous coverage).

I set JAVA_OPTS as follows,

-javaagent:<file_Path_for_jacoco_agent>/jacocoagent.jar=output=tcpserver,address=*,port=6300

Here is my repo link of tcp client - enter link description here

set fixed arguments to the code or create a jar with this repo

If you are running a jar from this code,

You can run this jar with passing "address" "port" "dump-folder-path" "periodic-time-for-dumping" "resetting-option-with-every-dump" arguments.

example : java -jar ExecutedDataDump.jar "127.0.0.1" "6300" "D:\\server-dumplog\\" "5" "noreset"

You will get get jacoco.exec files with time stamp in every 5 secs time and due to noreset every jacoco.exec is get cumulative report

Hope this will helpful for you.