Vipin Kumar - 2012-12-18

Hi

My testcases are in a different project while my code targeted to test is in a different project. I want to run all the junits and report to be build using the ant script. for me the error is coming that "no runtime coverage data found in any of the data files".

I tried a number of times  and a number of permutation and combination, but not successful. Please let me know what to do.

This is the code we are trying.

<?xml version="1.0" encoding="windows-1252" ?>
<!-Ant buildfile generated by Oracle JDeveloper->
<!-Generated Dec 18, 2012 10:19:24 AM->
<project name="ADFEmmaTest" default="all" basedir=".">
  <property file="build_junit.properties"/>
  <path id="library.JUnit.4.Runtime">
    <pathelement location="${oracle.home}/jdev/extensions/oracle.jdeveloper.junit/junit4.5/junit-4.5.jar"/>
  </path>
  <path id="classpath">
    <pathelement location="../ADFEmmaRun/classes"/>
    <pathelement location="${oracle.home}/jdev/extensions/oracle.jdeveloper.junit/junit4.5/junit-4.5.jar"/>
    <path refid="library.JUnit.4.Runtime"/>
  </path>
  <target name="init">
    <tstamp/>
    <mkdir dir="${output.dir}"/>
  </target>
  <target name="all" description="Build the project" depends="compile,copy"/>
  <target name="clean" description="Clean the project">
    <delete includeemptydirs="true" quiet="true">
      <fileset dir="${output.dir}" includes="**/*"/>
    </delete>
  </target>
  <target name="compile" description="Compile Java source files" depends="init">
    <javac destdir="${output.dir}" classpathref="classpath"
           debug="${javac.debug}" nowarn="${javac.nowarn}"
           deprecation="${javac.deprecation}" encoding="Cp1252" source="1.6"
           target="1.6">
      <src path="src"/>
    </javac>
  </target>
  <target name="copy" description="Copy files to output directory"
          depends="init">
    <patternset id="copy.patterns">
      <include name="**/*.gif"/>
      <include name="**/*.jpg"/>
      <include name="**/*.jpeg"/>
      <include name="**/*.png"/>
      <include name="**/*.properties"/>
      <include name="**/*.xml"/>
      <include name="**/*.ejx"/>
      <include name="**/*.xcfg"/>
      <include name="**/*.cpx"/>
      <include name="**/*.dcx"/>
      <include name="**/*.sva"/>
      <include name="**/*.wsdl"/>
      <include name="**/*.ini"/>
      <include name="**/*.tld"/>
      <include name="**/*.tag"/>
      <include name="**/*.xlf"/>
      <include name="**/*.xsl"/>
      <include name="**/*.xsd"/>
    </patternset>
    <copy todir="${output.dir}">
      <fileset dir="src">
        <patternset refid="copy.patterns"/>
      </fileset>
    </copy>
  </target>
  
   <property name="emma.dir" value="${oracle.home}/jdev/extensions/accenture.testUtils.extension/lib/" />
   <path id="emma.lib" >
     <pathelement location="${emma.dir}/emma.jar" />
     <pathelement location="${emma.dir}/emma_ant.jar" />   
  </path>

 
 
 
   <property name="src" value="../ADFEmmaRun/src" /> 
   <property name="test.src" value="../ADFEmmaTest/src" /> 
   <property name="classes" value="../ADFEmmaRun/classes" /> 
   <property name="test.classes" value="../ADFEmmaTest/classes" />
  
   <path id="allsrc">
        <pathelement location="../ADFEmmaTest/src"/>
        <pathelement location="../ADFEmmaRun/src"/>
   </path>
  
  
  
  
   <property name="emma.instr.dir" value="../ADFEmmaTest/build/instrumentation" />
   <property name="emma.coverage.dir" value="../ADFEmmaTest/build/coverage" /> 
     
   
    <path id="test.classpath"> 
        <pathelement path="${src}" /> 
        <pathelement path="${test.src}" /> 
        <pathelement path="${classes}" /> 
        <pathelement path="${test.classes}" />         
        <pathelement path="${test.dir}" />         
        <pathelement path="${emma.instr.dir}" /> 

        <pathelement location="${emma.dir}/emma.jar" />
        <pathelement location="${emma.dir}/emma_ant.jar" />   
        <pathelement location="${oracle.home}/jdev/extensions/oracle.jdeveloper.junit/junit4.5/junit-4.5.jar"/>
    </path>   
   
     <path id="all.classes">
        <pathelement location="../ADFEmmaRun/classes" /> 
        <pathelement location="../ADFEmmaTest/classes" />    
     </path>
     
      
      <path id="allsrc">
        <pathelement path="${src}" /> 
        <pathelement path="${test.src}" />             
     </path> 
 
 
  <taskdef resource="emma_ant.properties" classpathref="test.classpath" />
   
    <target name="clean-compile-test"> 
        <delete dir="${test.classes}" /> 
        <delete dir="${emma.instr.dir}" /> 
        <delete dir="${emma.coverage.dir}" /> 
    </target> 
 
   
    <target name="compile-test" depends="clean-compile-test"> 
        <mkdir dir="${classes}" /> 
        <mkdir dir="${test.classes}" /> 
        <javac debug="on" srcdir="${src}" destdir="${classes}"> 
            <classpath refid="test.classpath" /> 
        </javac> 
       
        <javac debug="on" srcdir="${test.src}" destdir="${test.classes}"  classpathref="test.classpath"> 
            <classpath refid="test.classpath" /> 
        </javac> 
       
        <!- javac debug="on" srcdir="${test.src}" destdir="${classes}"  classpathref="test.classpath"> 
            <classpath refid="test.classpath" /> 
        </javac-> 
    </target> 
 
   
   
    <target name="emma-instrument" depends="compile-test"> 
        <mkdir dir="${emma.instr.dir}" /> 
        <mkdir dir="${emma.coverage.dir}" /> 
        <emma enabled="true"> 
            <instr instrpath="${classes}" destdir="${emma.instr.dir}" 
                metadatafile="${emma.coverage.dir}/coverage.emma" merge="true" /> 
        </emma>         
        <emma enabled="true"> 
            <instr instrpath="${test.classes}" destdir="${emma.instr.dir}" 
                metadatafile="${emma.coverage.dir}/coverage.emma" merge="true" /> 
        </emma>
       
    </target> 
 
 
    <target name="test-instrumented" depends="emma-instrument"> 
        <junit fork="yes" printsummary="yes" haltonfailure="no"> 
            <classpath refid="test.classpath" /> 
            <formatter type="plain" usefile="false" /> 
            <!-batchtest>             
                <fileset  dir="${classes}" includes="**/*Tests.class" /> 
            </batchtest-> 
           
            <jvmarg value="-Demma.coverage.out.file=${emma.coverage.dir}/coverage.emma" /> 
            <jvmarg value="-Demma.coverage.out.merge=true" /> 
        </junit> 
    </target> 
   
   
   
   
   
 
  <target name="emma-report" depends="test-instrumented"> 
        <emma enabled="true"> 
            <report sourcepath="${src}">                 
                <fileset dir="${emma.coverage.dir}"> 
                    <include name="*.emma" /> 
                </fileset> 
                <xml outfile="${emma.coverage.dir}/coverage.xml" />                 
                <html outfile="${emma.coverage.dir}/coverage.html" />
            </report> 
        </emma> 
    </target> 
   
      
   
   
    
      <target name="emma-report2" depends="test-instrumented"> 
         <emma enabled="true">
          <report >           
   
            <sourcepath>
              <dirset dir="../ADFEmmaTest/" >
                <include name="**/src" />
              </dirset>
              <dirset dir="../ADFEmmaRun/" >
                <include name="**/src" />
              </dirset>            
            </sourcepath>
              <fileset dir="${emma.coverage.dir}"> 
                    <include name="*.emma" /> 
            </fileset>
              <xml outfile="${emma.coverage.dir}/coverage.xml" />                 
              <html outfile="${emma.coverage.dir}/coverage.html" />
          </report>
        </emma>
    </target>
</project>