且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

与 Ant 集成的 Junit 测试因 ClassNotFoundException 失败

更新时间:2023-11-20 08:40:52

${testclasses.home} 目录不在 任务的类路径上.

The ${testclasses.home} directory is nowhere on a classpath for <junit> task.

我认为这是 com.test.MyTest 的类文件所在.

I think this is where class file for com.test.MyTest lives.

这是修改后的单元测试目标:

Here is modified unit-test target:

<target name="unit-test" depends="compile-tests">
    <junit printsummary="false" fork="off" haltonfailure="true">
        <classpath>
          <path refid="classpath-test"/>
          <fileset dir="${testclasses.home}"/>
        </classpath>

        <formatter type="brief" usefile="false" />

        <test name="com.test.MyTest" />

        <!--<batchtest todir="${reports.dir}" >
            <fileset dir="${testclasses.home}" >
                <exclude name="**/AllTests*"/>
                <include name="**/*Test.class" />
            </fileset>
        </batchtest>-->
    </junit>
</target>