My ant build.xml is working fine without using instrument of cobertura for code coverage!
As long as I put my test depends=instrument it fails.
It seemed to me that the cobertura instrument caused the class loading problem.
Anyone has an idea, what was wrong?
<target name="instrument" depends="compile"> <echo> ====== run target instrument ==== </echo> <!-- Remove the coverage data file and any old instrumentation. --> <delete file="${junit.dir}/cobertura.ser" /> <delete dir="${instrumented.dir}" /> <!-- Instrument the application classes, writing the instrumented classes into ${build.instrumented.dir}. --> <cobertura-instrument todir="${instrumented.dir}"> <!-- The following line causes instrument to ignore any source line containing a reference to log4j, for the purposes of coverage reporting. --> <ignore regex="org.apache.log4j.*" /> <fileset dir="${classes.dir}"> <!-- Instrument all the application classes, but don't instrument the test classes. --> <include name="**/*.class" /> <exclude name="**/Test*.class" /> </fileset> </cobertura-instrument> </target> <target name="test" description="Run JUnit Tests" depends="instrument"> <echo> ====== run JUnit Tests ==== </echo> <junit fork="true" dir="${junit.dir}" printsummary="on" haltonfailure="yes" failureProperty="test.failed"> <!-- Note the classpath order: instrumented classes are before the original (uninstrumented) classes. This is important. --> <classpath location="${instrumented.dir}" /> <classpath location="${classes.dir}" /> <!-- The instrumented classes reference classes used by the Cobertura runtime, so Cobertura and its dependencies must be on your classpath. --> <classpath refid="cobertura.classpath" /> <classpath refid="testclasspath" /> <formatter type="xml" /> <batchtest fork="yes" todir="${reports.xml.dir}"> <fileset dir="${test.src}"> <include name="**/Test*.java" /> </fileset> </batchtest> </junit> </target> <target name="coverage-check"> <cobertura-check branchrate="34" totallinerate="100" /> </target>