使用JUnit编译ant类路径问题

时间:2015-06-05 20:07:35

标签: java ant junit jar compilation

我遇到了ant的编译问题,这里找不到junit.jar是我的构建文件:

<path id="lib">
    <fileset dir="library">
        <include name="*.jar" />
    </fileset>
</path>

<target name="test">
    <mkdir dir="tmp/reports" />

      <mkdir dir="tmp/build" />
        <javac srcdir="test" destdir="tmp/build" includeantruntime="false">
            <classpath refid="lib" />
        </javac>
        <echo message="Build done" />


    <junit fork="yes" haltonfailure="yes">

        <batchtest todir="tmp/reports">
            <fileset dir="tmp/test">
                <include name="*.java" />
            </fileset>
        </batchtest>
        <formatter type="xml" usefile="true"/>
        <classpath refid="test.classpath" />
    </junit>
</target>

我不确定我理解,因为-verbose模式下的蚂蚁确实找到了我JUnit jar看到附带的截图:

error

1 个答案:

答案 0 :(得分:2)

这应该在Ant中编译好。确保您使用的是最新版本的JUnit。旧版本(例如3.8.1)具有与JUnit 4.x不同的包层次结构。