我正在開發使用Eclipse的Eclipse SWT應用程序。還有一些JUnit 4測試,測試一些DAO的。但是當我嘗試通過ant build來運行測試時,所有的測試都失敗了,因爲沒有找到測試類。另一個Ant + JUnit類路徑問題
谷歌提出了大約100萬人都有同樣的問題,但他們的解決方案似乎沒有任何工作對我來說 - .-。
這是我的build.xml文件的內容:
<property name="test.reports" value="./test/reports" />
<property name="classes" value="build" />
<path id="project.classpath">
<pathelement location="${classes}" />
</path>
<target name="testreport">
<mkdir dir="${test.reports}" />
<junit fork="yes" printsummary="no" haltonfailure="no">
<batchtest fork="yes" todir="${test.reports}" >
<fileset dir="${classes}">
<include name="**/Test*.class" />
</fileset>
</batchtest>
<formatter type="xml" />
<classpath refid="project.classpath" />
</junit>
<junitreport todir="${test.reports}">
<fileset dir="${test.reports}">
<include name="TEST-*.xml" />
</fileset>
<report todir="${test.reports}" />
</junitreport>
</target>
的測試類是在構建目錄連同應用程序類,雖然它們在某些子根據自己的包。它可能也很重要:起初Ant抱怨說JUnit不在它的classpath中,但是由於我把它放在那裏(用eclipse配置編輯器),它抱怨JUnit在它的類路徑中兩次。
WARNING: multiple versions of ant detected in path for junit
[junit] jar:file:C:/Users/as df/Documents/eclipse/plugins/org.apache.ant_1.7.1.v20090120-1145/lib/ant.jar!/org/apache/tools/ant/Project.class
[junit] and jar:file:/C:/Users/as%20df/Documents/eclipse/plugins/org.apache.ant_1.7.1.v20090120-1145/lib/ant.jar!/org/apache/tools/ant/Project.class
我已經試過指定每一個子目錄,每一個類文件,我已經試過文件集的文件列表及,似乎沒有任何工作。
感謝您的幫助,我已經坐在了幾個小時就現在這件事情......
你介意寫下用戶名「as_df」而不是「as df」(用下劃線替換空白)嗎? – stacker 2010-05-10 19:02:01