我遇到了 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
模式下的 ant 确实找到了我 JUnit jar,请参阅随附的屏幕截图:
最佳答案
这应该可以在 Ant 中正常编译。确保您使用的是最新版本的 JUnit。旧版本(例如 3.8.1)具有与 JUnit 4.x 不同的包层次结构。
关于java - 使用 JUnit 的 ant 类路径编译问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30674947/