[junit] The ' characters around the executable and arguments are
[junit] not part of the command.
There are so many java.lang.ClassNotFoundException exceptions!Solution: (does not fit all)
To solve it, we should put the compiled Java classes in JUnit's classpath, say
<junit>
<classpath>
<pathelement location="${classes.dir}"/>
</classpath>
</junit>
The whole picture is that:
<path id="test.classpath">
<path refid="classpath" />
<fileset dir="${test.dir}/lib" />
</path>
<target name="test.compile">
<javac srcdir="${test.dir}" encoding="UTF-8" destdir="${classes.dir}"
includeantruntime="false" debug="true">
<classpath>
<path refid="test.classpath" />
</classpath>
<include name="**/*.java" />
</javac>
<copy todir="${classes.dir}">
<fileset dir="${test.dir}">
<exclude name="**/*.java"/>
</fileset>
</copy>
</target>
<target name="junit" depends="compile,test.compile">
<junit printsummary="yes">
<formatter type="plain" usefile="false"/>
<classpath>
<path refid="test.classpath" />
<pathelement location="${classes.dir}"/>
</classpath>
<batchtest fork="yes">
<fileset dir="${classes.dir}" includes="**/*Test.class"/>
</batchtest>
</junit>
</target>
Enjoy!
沒有留言:
張貼留言