Here's the target I'm using to run my tests:
<target name="run-tests" description="run the tests" depends="compilation">
<junit>
<sysproperty key="tests.basedir" value="${SPECIAL_PATH}/unit_tests"/>
<classpath>
<pathelement location="${COMPILED_CLASSES}"/>
<pathelement location="${basedir}/junit-4.8.1.jar"/>
</classpath>
<batchtest>
<fileset dir="${COMPILED_CLASSES}/unit_tests/">
<include name="**/Test*.class"/>
<exclude name="**/*$*"/>
</fileset>
</batchtest>
</junit>
</target>
However, every time I try to run this target, all my tests fail with something like:
[junit] java.lang.ClassNotFoundException: testpackage.TestMyClass
[junit] at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
[junit] at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
[junit] at java.lang.Class.forName0(Native Method)
[junit] at java.lang.Class.forName(Class.java:247)
The SPECIAL_PATH
property points to the source code of the classes. The COMPILED_CLASSES
property points to the place the .class
files have been put. And I need the tests.basedir
property because I use it from my unit tests.
What am I doing wrong?
EDIT:I also thought I should explain the exclude of the $
. I'm excluding anonymous classes, because they don't represent TestCases, they're only used from them.