Wednesday, December 25, 2013

JUnit ANT Script

This is an example of running JUnit using ANT script.

<?xml version="1.0" encoding="UTF-8"?>

<!-- Description :This ANT script execute JUnit. -->
<project default="junit.script" name="Example JUnit script.">
<property environment="env"/>
<property name="junit.lib" value="C:/jboss-as-7.1.1.Final/standalone/cit/lib"/>
<property name="junit.reports.dir" value="C:/jboss-as-7.1.1.Final/standalone/cit/reports/junit_ws_ext"/>
<property name="test.classes.dir" value="C:/jboss-as-7.1.1.Final/standalone/cit/reports/junit_ws_ext/test_classes"/>
<property name="report.dir" value="Z:/"/>

<path id="JUNIT.lib"> 
<fileset dir="${junit.lib}"> 
<include name="**/*.jar" /> 
</fileset> 
</path>

<path id="TEST.classes"> 
<fileset dir="${test.classes.dir}"> 
<include name="**/*.jar" /> 
</fileset> 
</path>

<taskdef name="junit"  classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTask">
<classpath refid="JUNIT.lib" /> 
</taskdef>

<target name="junit.ws.ext.script" depends="junit.ext.script,copy.script"/> 

<target name="junit.ext.script">
<junit fork="yes" printsummary="withOutAndErr" >
<formatter type="xml"/>
<test name="com.mago.AllTests" todir="${junit.reports.dir}"/>
<classpath refid="JUNIT.lib"/>
<classpath refid="TEST.classes"/>
</junit>
<junitreport todir="${junit.reports.dir}/junit_ws_ext_result">
<fileset dir="${junit.reports.dir}">
<include name="TEST-*.xml"/>
</fileset>
<report format="frames" todir="${junit.reports.dir}/junit_ws_ext_result"/>
</junitreport>
</target>

<target name="copy.script">
<copydir src="${junit.reports.dir}/junit_ws_ext_result"  dest="${report.dir}/junit_ws_ext"/>
</target>


</project>

No comments:

Post a Comment