I'm using ant to build my java program. It's compiling fine but when I go to run the unit test class it can't find Class Files. I've messed with my classpath a ton and this exception keeps coming up?
The jars in lib are as follows:
- ant.jar
- hamcrest.jar
- hamcrest-core-1.3.jar
- hamcrest-all-1.3.jar
- hamcrest-core.jar
- junit.jar
Buildfile build.xml
:
<project name="PillarWorkspaceHiring" default="test" basedir=".">
<description>
Author: April Randolph for a evening of babysitting. Uses Ant to build the junit, hamcrest java program.
Babysitting Kata
</description>
<!-- Set global properties for this build -->
<property name="test.src.dir" value="src/main/java"/>
<property name="test.build.dir" value="build/test"/>
<property name="main.build.dir" value="build/main"/>
<property name="main.src.dir" value="src/main/java"/>
<property name="full-compile" value="true"/>
<target name="clean" description="clean up">
<!-- Delete the ${dir.build} -->
<delete verbose="${full-compile}" >
<fileset dir="${main.build.dir}" includes="**/*.class" />
<fileset dir="${test.build.dir}" includes="**/*.class" />
</delete>
</target >
<path id="classpath.test">
<pathelement location="lib/junit-4.12.jar"/>
<pathelement location="lib/hamcrest-core-1.3.jar"/>
<pathelement location="lib/ant.jar"/>
<pathelement location="${main.build.dir}"/>
</path>
<!-- Testsuite-->
<target name="test" depends="test-compile" >
<junit printsummary="on" haltonfailure="yes" fork="true">
<classpath>
<path refid="classpath.test"/>
<pathelement location="${test.build.dir}"/>
</classpath>
<formatter type="brief" usefile="false" />
<batchtest>
<fileset dir="${test.src.dir}" includes="**/*Test*.java" />
</batchtest>
</junit>
</target>
<!-- Build main class files -->
<target name="compile" >
<mkdir dir="${main.build.dir}"/>
<javac srcdir="${main.src.dir}" destdir="${main.build.dir}" includeantruntime="false">
<classpath refid="classpath.test"/>
</javac>
</target>
<target name="test-compile" depends="compile">
<mkdir dir="${test.build.dir}"/>
<javac srcdir="${test.src.dir}" destdir="${test.build.dir}" includeantruntime="false">
<classpath refid="classpath.test"/>
</javac>
</target>
</project>
inflated: hamcrest\SelfDescribing.class
I get this from the console
test:
What am I doing wrong?
lib/ant.jar
from the classpath. - Stefan Birkner