【发布时间】:2016-03-01 14:38:26
【问题描述】:
我已经能够使用 ant 成功编译和运行这个项目。但是当我尝试运行我的测试文件时,它给了我一个奇怪的 Reference ./lib/junit-4.11.jar not found。我可能在 junit 任务中必须提到的 refid 中做错了什么。请指出错误。
<target name="clean">
<delete dir="build"/>
</target>
<target name="compile">
<mkdir dir="build/classes"/>
<javac srcdir="./src/com/twu/biblioteca/" destdir="build/classes"/>
</target>
<target name="jar">
<mkdir dir="build/jar"/>
<jar destfile="build/jar/Application.jar" basedir="build/classes">
<manifest>
<attribute name="Main-Class" value="com.twu.biblioteca.Application"/>
</manifest>
</jar>
</target>
<target name="run">
<java jar="build/jar/Application.jar" fork="true"/>
</target>
<target name="junit" depends="compile">
<junit printsummary="yes" haltonfailure="no">
<!-- Project classpath, must include junit.jar -->
<classpath refid="./lib/junit-4.11.jar" />
<!-- test class -->
<classpath location="./test/BooksController" />
<test name="com.twu.biblioteca.BooksControllerTest"
haltonfailure="no" todir="./report">
<formatter type="plain" />
<formatter type="xml" />
</test>
</junit>
</target>
【问题讨论】: