Menu

Missing coverage data for all Tests but the last one

Developers
2015-11-17
2015-11-17
  • - 2015-11-17

    The example ant target at the bottom instruments and executes all tests of the directory but produces only a coverage report for the very last *Test.java file. Any suggestions why?

    <target name="emma">
            <property name="emma.enabled" value="true" />
    
            <mkdir dir="${out.instr.dir}" />
    
            <property name="emma.filter" value="" />
        </target>
    
        <target name="test" depends="compile-test, emma">
                <emma enabled="${emma.enabled}" >
                    <instr instrpathref="build.main.path"
                        destdir="${out.instr.dir}"  
                        metadatafile="${coverage.dir}/metadata.emma"
                        merge="true"
                    >
                        <filter value="${emma.filter}" />
                    </instr>
                </emma>
    
                <junit printsummary="on" fork="true" haltonfailure="yes">
    
                    <classpath>
                        <pathelement location="${out.instr.dir}" />             
                        <pathelement location="build/main" />
                        <pathelement location="build/evosuite-tests"/>
                        <path refid="lib.path"/>
                        <path refid="emma.lib.path" />
                    </classpath> 
    
                    <formatter type="xml" />                        
                    <batchtest todir="testreport">
                        <fileset dir="tests"> 
                            <include name="**/*Test.java"/>
                        </fileset>
                    </batchtest>
    
                    <jvmarg value="-Demma.coverage.out.file=${coverage.dir}/coverage.emma" />
                    <jvmarg value="-Demma.coverage.out.merge=false" />
    
                </junit>
    
                <emma enabled="${emma.enabled}" >
                <report sourcepath="src/main"
                    sort="+block,+name,+method,+class"
                    metrics="method:70,block:80,line:80,class:100">
    
                <fileset dir="${coverage.dir}" >
                    <include name="*.emma" />
                </fileset>
    
                <txt outfile="${coverage.dir}/coverage.txt"
                    depth="package"
                    columns="class,method,block,line,name"
                />
                <xml outfile="${coverage.dir}/coverage.xml"
    
                    depth="package"
                />
                <html outfile="${coverage.dir}/coverage.html"
                    depth="method"
                    columns="name,class,method,block,line"
    
                />
                </report>
            </emma>
            </target>
    
     
    • Marc R. Hoffmann

      Hi,

      this is because you fork a new JVM for every test (fork="true") and you
      ask EMMA to overwrite coverage data (-Demma.coverage.out.merge=false).

      Either fork once only (forkmode="once") or ask EMMA to merge coverage data.

      Nice to see somebody still working with EMMA ;-)

      Regards,
      -marc

      On 17.11.15 22:30, Henrik Schole wrote:

      The example ant target at the bottom instruments and executes all
      tests of the directory but produces only a coverage report for the
      very last *Test.java file. Any suggestions why?

      <target name="emma">
      <property name="emma.enabled" value="true"/>

           <mkdir  dir="${out.instr.dir}"  />
      
           <property  name="emma.filter"  value=""  />
       </target>
      
       <target  name="test"  depends="compile-test, emma">
               <emma  enabled="${emma.enabled}"  >
                   <instr  instrpathref="build.main.path"
                       destdir="${out.instr.dir}"   
                       metadatafile="${coverage.dir}/metadata.emma"
                       merge="true"
                   >
                       <filter  value="${emma.filter}"  />
                   </instr>
               </emma>
      
               <junit  printsummary="on"  fork="true"  haltonfailure="yes">
      
                   <classpath>
                       <pathelement  location="${out.instr.dir}"  />              
                       <pathelement  location="build/main"  />
                       <pathelement  location="build/evosuite-tests"/>
                       <path  refid="lib.path"/>
                       <path  refid="emma.lib.path"  />
                   </classpath>
      
                   <formatter  type="xml"  />                         
                   <batchtest  todir="testreport">
                       <fileset  dir="tests">  
                           <include  name="**/*Test.java"/>
                       </fileset>
                   </batchtest>
      
                   <jvmarg  value="-Demma.coverage.out.file=${coverage.dir}/coverage.emma"  />
                   <jvmarg  value="-Demma.coverage.out.merge=false"  />
      
               </junit>
      
               <emma  enabled="${emma.enabled}"  >
               <report  sourcepath="src/main"
                   sort="+block,+name,+method,+class"
                   metrics="method:70,block:80,line:80,class:100">
      
               <fileset  dir="${coverage.dir}"  >
                   <include  name="*.emma"  />
               </fileset>
      
               <txt  outfile="${coverage.dir}/coverage.txt"
                   depth="package"
                   columns="class,method,block,line,name"
               />
               <xml  outfile="${coverage.dir}/coverage.xml"
      
                   depth="package"
               />
               <html  outfile="${coverage.dir}/coverage.html"
                   depth="method"
                   columns="name,class,method,block,line"
      
               />
               </report>
           </emma>
           </target>
      

      Missing coverage data for all Tests but the last one
      https://sourceforge.net/p/emma/discussion/373867/thread/ae0e0365/?limit=25#5865


      Sent from sourceforge.net because you indicated interest in
      https://sourceforge.net/p/emma/discussion/373867/

      To unsubscribe from further messages, please visit
      https://sourceforge.net/auth/subscriptions/

       
      • - 2015-11-17

        easy :) the output looks much better now. thanks!

         
    • Andreas

      Andreas - 2015-11-17

      Without looking at my build.xml files...

      I guess merge should be true in:
      <jvmarg value="-Demma.coverage.out.merge=false"/>

      On 17 Nov 2015 at 21:30, Henrik Schole wrote:

      The example ant target at the bottom instruments and executes all tests of the directory but produces only a coverage report for the very last *Test.java file. Any suggestions why?

      ~~~~
      <target name="emma">
      <property name="emma.enabled" value="true"/>

        <mkdir dir="${out.instr.dir}" />
      
        <property name="emma.filter" value="" />
      

      </target>

      <target name="test" depends="compile-test, emma">
              <emma enabled="${emma.enabled}" >
                <instr instrpathref="build.main.path"
                    destdir="${out.instr.dir}"  
                    metadatafile="${coverage.dir}/metadata.emma"
                    merge="true"
                >
                    <filter value="${emma.filter}" />
                </instr>
            </emma>
      
              <junit printsummary="on" fork="true" haltonfailure="yes">
      
                <classpath>
                      <pathelement location="${out.instr.dir}" />               
                    <pathelement location="build/main" />
                    <pathelement location="build/evosuite-tests"/>
                      <path refid="lib.path"/>
                      <path refid="emma.lib.path" />
                  </classpath>
      
                  <formatter type="xml" />                        
                  <batchtest todir="testreport">
                      <fileset dir="tests"> 
                          <include name="**/*Test.java"/>
                      </fileset>
                  </batchtest>
      
                  <jvmarg value="-Demma.coverage.out.file=${coverage.dir}/coverage.emma" />
                  <jvmarg value="-Demma.coverage.out.merge=false" />
      
              </junit>
      
              <emma enabled="${emma.enabled}" >
            <report sourcepath="src/main"
                sort="+block,+name,+method,+class"
                metrics="method:70,block:80,line:80,class:100">
      
            <fileset dir="${coverage.dir}" >
                <include name="*.emma" />
            </fileset>
      
            <txt outfile="${coverage.dir}/coverage.txt"
                depth="package"
                columns="class,method,block,line,name"
            />
            <xml outfile="${coverage.dir}/coverage.xml"
      
                depth="package"
            />
            <html outfile="${coverage.dir}/coverage.html"
                depth="method"
                columns="name,class,method,block,line"
      
            />
            </report>
        </emma>
          </target>
      

      ~~~~


       
      • - 2015-11-17

        yes this was the problem. Thanks for the quick response!

         

Log in to post a comment.