1

I'm trying to get coverage data remotely with jacoco agent and reset execution info on server with reset=true;

jacoco java agent on server:

JAVA_OPTIONS="${JAVA_OPTIONS} -javaagent:applications/jacoco/lib/jacocoagent.jar=output=tcpserver,address=*,port=36320"

Ant task on local machine:

<project name="Ant Report Build with JaCoCo" default="get_data" xmlns:jacoco="antlib:org.jacoco.ant">

    <property name="result.exec.file" value="test_data.exec"/>
    <property name="server" value="my-server.com" />
    <property name="port" value ="36320" />

    <taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml">
      <classpath path="jacoco\lib\jacocoant.jar"/>
    </taskdef>   


    <target name="get_data">
      <jacoco:dump address="${server}" port="${port}" reset="true" append="false" destfile="${result.exec.file}"/>
    </target>

</project>

My problem is in resetting execution info after I get dump. If I do some actions on server and then call my ant target "get_data" twice,deleting test_data.exec file between the executions, I get the same coverege data. So it seems that reset=true doesn't work.

How can I make Jacoco to reset coverega data info after I dump it? Would appreciate any help.

pomkine
  • 1,605
  • 4
  • 18
  • 29

2 Answers2

2

I encountered same problem. But please take a closer look and you'll find that the 2 coverage data dumps you have are not same. They are same in size, but not when you "diff" them.

When you call to "reset", it's easy to assume that jacocoagent is going to wipe out all execution data, and your next dump is expected to be 0 in size, but that's not the case. Instead, jacocoagent reset all execution data all to be "not executed", and what you dump next will be a file marking everything not executed, not an empty file. The jacoco.exec file size is associated with how many classes have been loaded into JVM.

Rick Sun
  • 56
  • 4
0

Seems that you have lost dump="true" and quietly delete the file with ant. Should be

<jacoco:dump address="${server}" port="${port}" dump="true" reset="true" destfile="${result.exec.file}" append="false"/>
<delete file="${result.exec.file}"/>

More info here

Community
  • 1
  • 1
ZuzEL
  • 12,768
  • 8
  • 47
  • 68