How to merge multiple jacoco exec data

663 views
Skip to first unread message

giridha...@gmail.com

unread,
Mar 9, 2020, 7:58:31 AM3/9/20
to JaCoCo and EclEmma Users
Hi There,

I am running  junit for two packages in parallel way using ant script.But when I am trying to merge both exec ,it doesn't give full report result.

Please find the ant script below.

<target name="test" description="Run unit tests" depends="compile">

<parallel threadCount="2">
<antcall inheritall="false" target="test1"/>
<antcall inheritall="false" target="test2"/>

               </parallel>
 </target>



<target name="test1">
  <echo message="Running unit tests in pkg 1..."/>
     <jacoco:coverage destfile="${unit.test.dir}/jacoco1.exec" >
       <junit printsummary="false"   haltonfailure="off" fork="true"  showoutput="yes" >
        <classpath>
          <pathelement location="${test.classes.dir}"/>  
          <path refid="classpath" />
        </classpath>
        <formatter type="xml"/>
        <batchtest fork="true" todir="${result.dir}">
          <fileset dir="${test.classes.dir}" casesensitive="yes">
          <!-- All the classes pkg 2 will be excluded -->
            <exclude name="**/pkg2/**" />
              <include name="**/*Test*.class"/> 
          </fileset>
        </batchtest>
      </junit>
     </jacoco:coverage>
</target>

<target name="test2">
  <echo message="Running unit tests in pkg 2..."/>
     <jacoco:coverage destfile="${unit.test.dir}/jacoco2.exec" >
       <junit printsummary="false"   haltonfailure="off" fork="true"  showoutput="yes" >
        <classpath>
          <pathelement location="${test.classes.dir}"/>  
          <path refid="classpath" />
        </classpath>
        <formatter type="xml"/>
        <batchtest fork="true" todir="${result.dir}">
          <fileset dir="${test.classes.dir}" casesensitive="yes">
          <!-- All the classes pkg 1 will be excluded -->
            <exclude name="**/pkg1/**" />
               <include name="**/*Test*.class"/> 
          </fileset>
        </batchtest>
      </junit>
     </jacoco:coverage>
</target>




<!-- Report -->

<target name="test.report">

  <jacoco:merge destfile="${unit.test.dir}/merged.exec">
    <fileset dir="${unit.test.dir}" includes="*.exec" />
  </jacoco:merge>

 <jacoco:report>
      <executiondata>
         <file file="${unit.test.dir}/merged.exec"/>
       </executiondata>

    <structure name ="test">
     <classfiles>
       <fileset dir="${classes.dir}">
        <include name="**/impl/*.class"/>
      <exclude name="**/*Test*"/>
        </fileset>
    </classfiles>

    </structure>
    
    <html destdir="${dir.bld.sg.jacoco.report}"/>
    
  </jacoco:report>
  
</target>


I tried to use same sessionID for both jacoco coverage, but it also didn't work.

Running all junits in sequential way generate report as expected.


Please let me know what am I missing.

Thank you.
Giridhar
Message has been deleted
Message has been deleted

Evgeny Mandrikov

unread,
Mar 26, 2020, 9:18:04 AM3/26/20
to jac...@googlegroups.com
On Mon, Mar 9, 2020 at 12:58 PM <giridha...@gmail.com> wrote:
Hi There,

I am running  junit for two packages in parallel way using ant script.But when I am trying to merge both exec ,it doesn't give full report result.

Please find the ant script below.

Partial snippets are not debuggable, so to not waste the time of others on attempts to reproduce your setup and to increase your chances of receiving help, please always include a complete example.

In the attached "example.zip" you'll find a complete example that executes tests in parallel, merges two exec files and generates the following report for merged exec file

report.png

while following two for individual exec files


report1.png

report2.png


example.zip

jing jing

unread,
Mar 18, 2021, 11:24:08 AM3/18/21
to JaCoCo and EclEmma Users
May I ask you to obtain the coverage of method pkg2 first, before obtaining the coverage of pkg1, did you modify the code and republish it, and then obtain pkg2, or should you continue to obtain pkg2 without changes to the code?
Reply all
Reply to author
Forward
0 new messages