Ant + JUnit = ClassNotFoundExceptions when running tests?
- by rfkrocktk
I'm trying to run some tests in Ant presently using JUnit, and all of my tests are failing with the following stacktrace:
java.lang.ClassNotFoundException: com.mypackage.MyTestCase
It doesn't make too much sense to me. I'm first compiling my test cases using <javac>, then directly running the <junit> task to run the tests. My buildfile looks like this:
<target name="compile.webapp.tests">
<javac srcdir="${test.java.src.dir}"
destdir="${test.java.bin.dir}">
<classpath>
<filelist>
<file name="${red5.home}/red5.jar"/>
<file name="${red5.home}/boot.jar"/>
<file name="${bin.dir}/${ant.project.name}.jar"/>
</filelist>
<fileset dir="${red5.lib.dir}" includes="**/*"/>
<fileset dir="${main.java.lib.dir}" includes="**/*"/>
<fileset dir="${test.java.lib.dir}" includes="**/*"/>
</classpath>
</javac>
</target>
<target name="run.webapp.tests">
<junit printsummary="true">
<classpath>
<filelist>
<file name="${red5.home}/red5.jar"/>
<file name="${red5.home}/boot.jar"/>
<file name="${bin.dir}/${ant.project.name}.jar"/>
</filelist>
<fileset dir="${red5.lib.dir}" includes="**/*.jar"/>
<fileset dir="${main.java.lib.dir}" includes="**/*.jar"/>
<fileset dir="${test.java.lib.dir}" includes="**/*.jar"/>
</classpath>
<formatter type="xml"/>
<batchtest todir="${test.java.output.dir}">
<fileset dir="${test.java.bin.dir}" includes="**/*TestCase*"/>
</batchtest>
</junit>
</target>
This is really weird, I can't seem to fix this. Is there something I'm doing wrong here?