小编syl*_*sau的帖子

与Ant失败的Junit测试与ClassNotFoundException失败

我对我的项目进行了JUnit测试,可以正确运行Eclipse.

所以,现在我尝试将这些测试与ant任务集成.为此,我制作了以下蚂蚁脚本:

<path id="classpath-test">
    <pathelement path="." />
    <pathelement path="${classes.home}" />
    <fileset dir="${lib.home}" includes="*.jar" />
    <fileset dir="${libtest.home}" includes="*.jar" />
</path>

    <target name="compile" ... > // compiles src code of the project

<target name="compile-tests" depends="compile">
    <javac  srcdir="${test.home}"
            destdir="${testclasses.home}" 
            target="1.5"
            source="1.5" 
            debug="true"
        >
        <classpath refid="classpath-test" />
    </javac>

    <copy todir="${testclasses.home}">
        <fileset dir="${test.home}">
            <exclude name="**/*.java"/>
        </fileset>
    </copy>
</target>

<target name="unit-test" depends="compile-tests">
    <junit printsummary="false" fork="off" haltonfailure="true">
        <classpath refid="classpath-test" />

        <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" …
Run Code Online (Sandbox Code Playgroud)

ant junit classnotfoundexception

6
推荐指数
1
解决办法
5491
查看次数

标签 统计

ant ×1

classnotfoundexception ×1

junit ×1