亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

在Ant,Ivy和JUnit中找不到類-build.xml中的錯誤?

在Ant,Ivy和JUnit中找不到類-build.xml中的錯誤?

LEATH 2019-12-06 10:01:01
我正在嘗試使用Ant,Ivy和JUnit進行一個簡單的(?)測試項目。基本思想是Ivy將下載junit.jar,然后Ant將使用它。請注意,junit jar位于類路徑上,因為否則(classpath在junit任務中沒有元素),我會看到“ <junit>的<classpath>必須包含junit.jar(如果不在Ant自己的類路徑中)”。另外,下面給出的類(junit.framework.TestListener)在junit-4.8.2.jar中。但是,當我嘗試ant test以下操作時,我看到:test:BUILD FAILED/home/andrew/project/guice/hg/build.xml:33: java.lang.NoClassDefFoundError: junit/framework/TestListener        at java.lang.ClassLoader.defineClass1(Native Method)        at java.lang.ClassLoader.defineClass(ClassLoader.java:791)...        at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)        at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)Caused by: java.lang.ClassNotFoundException: junit.framework.TestListener        at java.net.URLClassLoader$1.run(URLClassLoader.java:366)        at java.net.URLClassLoader$1.run(URLClassLoader.java:355)...所以我猜我的build.xml有問題嗎?什么?這是build.xml:<project xmlns:ivy="antlib:org.apache.ivy.ant"          name="java-example" default="dist" basedir=".">  <description>    simple example build file  </description>  <property name="src" location="src"/>  <property name="build" location="build"/>  <property name="dist" location="dist"/>  <property name="lib" location="lib"/>  <path id="lib.path">    <fileset dir="${lib}"/>  </path>  <target name="init">    <tstamp/>    <mkdir dir="${build}"/>  </target>  <target name="compile" depends="init,resolve"          description="compile the source">    <javac srcdir="${src}" destdir="${build}" classpathref="lib.path"           includeantruntime="false">      <compilerarg value="-Xlint"/>    </javac>  </target>  <target name="test" depends="compile"          description="run the tests">    <junit>      <classpath refid="lib.path"/>      <batchtest>        <fileset dir="${build}">          <include name="**/*Test.class"/>        </fileset>      </batchtest>    </junit>  </target>
查看完整描述

2 回答

?
蝴蝶刀刀

TA貢獻1801條經驗 獲得超8個贊

我正在使用1.9.0。您確定沒有在ant / lib或類似文件中安裝junit jar嗎?不知道我是否足夠清楚地解釋了我是否試圖使其不起作用(根據我所鏈接的說明應該是可能的)。感謝您的更新-不確定它如何解決我的問題,但我想我可以嘗試一下,如果可以,請慢慢減小它,直到回到問題為止。

查看完整回答
反對 回復 2019-12-06
  • 2 回答
  • 0 關注
  • 854 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號