Skip to content

Commit a6f12f9

Browse files
committed
Added unit tests to ant build file
1 parent 22bc3db commit a6f12f9

File tree

1 file changed

+37
-12
lines changed

1 file changed

+37
-12
lines changed

build.xml

+37-12
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<project name="java-algorithms-implementation" default="dist" basedir=".">
1+
<project name="java-algorithms-implementation" default="test" basedir=".">
22
<description>
33
java-algorithms-implementation build file
44
</description>
@@ -8,38 +8,63 @@
88
<property name="build" location="build"/>
99
<property name="dist" location="dist"/>
1010

11-
<target name="init">
12-
<!-- Create the time stamp -->
13-
<tstamp/>
14-
<!-- Create the build directory structure used by compile -->
15-
<mkdir dir="${build}"/>
16-
<!-- Create the dist directory structure used by compile -->
17-
<mkdir dir="${dist}"/>
18-
</target>
19-
2011
<path id="class.path">
2112
<fileset dir="lib">
2213
<include name="**/*.jar" />
2314
</fileset>
2415
</path>
2516

26-
<target name="compile" depends="init" description="compile the source">
17+
<path id="test.class.path">
18+
<fileset dir="lib">
19+
<include name="**/*.jar" />
20+
</fileset>
21+
<fileset dir="dist">
22+
<include name="**/*.jar" />
23+
</fileset>
24+
</path>
25+
26+
<target name="init" depends="clean">
27+
<!-- Create the time stamp -->
28+
<tstamp/>
29+
<!-- Create the build directory structure used by build -->
30+
<mkdir dir="${build}"/>
31+
<!-- Create the dist directory structure used by build -->
32+
<mkdir dir="${dist}"/>
33+
</target>
34+
35+
<target name="build" depends="init" description="build the source">
2736
<!-- Compile the java code from ${src} into ${build} -->
2837
<javac srcdir="${src}" destdir="${build}">
2938
<classpath refid="class.path" />
3039
</javac>
3140
</target>
3241

33-
<target name="dist" depends="compile" description="generate the distribution">
42+
<target name="dist" depends="build" description="generate the distribution">
3443
<!-- Create the distribution directory -->
3544

3645
<!-- Put everything in ${build} into the java-algorithms-implementation-${DSTAMP}.jar file -->
3746
<jar jarfile="${dist}/java-algorithms-implementation-${DSTAMP}.jar" basedir="${build}"/>
3847
</target>
3948

49+
<target name="run_tests" depends="dist">
50+
<junit printsummary="on" haltonfailure="yes">
51+
<classpath>
52+
<path refid="test.class.path" />
53+
<!-- pathelement location="${build}"/ -->
54+
</classpath>
55+
<formatter type="brief" usefile="false" />
56+
<batchtest>
57+
<fileset dir="${src}" includes="**/test/*.java" excludes="**/test/AllTests.java" />
58+
</batchtest>
59+
</junit>
60+
</target>
61+
62+
<target name="test" depends="run_tests" />
63+
4064
<target name="clean" description="clean up">
4165
<!-- Delete the ${build} and ${dist} directory trees -->
4266
<delete dir="${build}"/>
4367
<delete dir="${dist}"/>
4468
</target>
69+
4570
</project>

0 commit comments

Comments
 (0)