I am integrating junit test cases with my current project that uses ant build files. I have added a few test cases, and they are running perfectly as part of build process. I need to generate a detailed and relevant report of junit along with build. Inside <junit>
, I am using <formatter>
. I am facing following issues:
- If I use
<formatter type="plain">
, it contains very limited information. - If I use
<formatter type="xml>
, it prints too many properties. - I tried writing a custom formatter using
org.apache.tools.ant.taskdefs.optional.junit.JUnitResultFormatter
. For this, I need to addant-x.x.x.jar
andant-junit-x.x.x.jar
in build file<classpath>
. It gives "two different ant versions are present"
Question-1: Is there any way by which we can restrict or filter the XML elements to be printed in reports, maybe by overriding XML formatter or some other way?
Question-2: How can I avoid the above exception of "two different ant version"?
I would prefer if there is some option for question-1.
[UPDATE-1] My JUnit task in Ant:
<target name="unit_testing" depends="binary" description="Unit Testing">
<!-- Compile the java code from ${src} into ${build_main} -->
<javac srcdir="${codebase_test}" destdir="${build_test}"
encoding="cp1252" includeantruntime="false"
bootclasspath="C:/Program Files (x86)/Java/jdk1.5.0_07/jre/lib/rt.jar;C:/Program Files/Java/jdk1.5.0_07/jre/lib/rt.jar;"
source="1.5" target="1.5">
<classpath refid="classpath_main" />
<classpath refid="classpath_test" />
<classpath>
<pathelement location="${binary}/binary_x.x.x.jar" />
</classpath>
</javac>
<junit fork="yes" haltonfailure="yes">
<!-- set useFile="true" if output required in files -->
<formatter type="xml" usefile="true" />
<classpath refid="classpath_main" />
<classpath refid="classpath_test" />
<classpath>
<pathelement path="${build_test}" />
<pathelement location="${binary}/binary_x.x.x.jar" />
</classpath>
<batchtest todir="${results_test}">
<fileset dir="${build_test}">
<include name="**/*Test.class" />
</fileset>
</batchtest>
</junit>
</target>