My build.xml can run junitTest well but when I tried to build with cobertura instrument, JunitTest failed, Why?
<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>
Anything missing?
target "test":
change the depends="compile", it works fine.
as long as depends="instrument", Junit test failed.
It seemed to me that instrument destroyed junit class path, or something....