View RSS Feed

My Java Tips

Running JUnit using Ant

Rate this Entry
by , 05-21-2011 at 10:26 PM (2655 Views)
You may want to define build script using ant for your application. I will write about how to create ant script to run ant.

Step 1: define ant properties

XML Code:
<property name="src" value="./src" />
<property name="lib" value="./lib" />
<property name="classes" value="./classes" />
<property name="" value="" />
Step 2: set CLASSPATH to be used by JUnit

XML Code:
<path id="test.classpath">
<pathelement location="${classes}" />
<pathelement location="/path/to/junit.jar" /><fileset dir="${lib}">
<include name="**/*.jar"/>
Step 3: define the ant task for running JUnit

XML Code:
<target name="test">
<junit fork="yes" haltonfailure="yes">
<test name="${}" />
<formatter type="plain" usefile="false" />
<classpath refid="test.classpath" />
Step 4: run the test

Java Code:
ant test

Submit "Running JUnit using Ant" to Facebook Submit "Running JUnit using Ant" to Digg Submit "Running JUnit using Ant" to Submit "Running JUnit using Ant" to StumbleUpon Submit "Running JUnit using Ant" to Google

Tags: ant Add / Edit Tags