2011-07-08 82 views
8

我想使用螞蟻(後1.7)運行在一個名爲* Test.class類在某個jar中的所有測試。從罐子螞蟻junit batchtest

類似下面的(雖然它實際上並沒有運行任何測試):

<junit fork="yes" printsummary="on" haltonfailure="on"> 
     <formatter type="xml"/> 
     <batchtest fork="yes" todir="${junit.output.dir}"> 
      <resources> 
       <zipentry zipfile="tests-only.jar" name="**/*Test.class"/> 
      </resources> 
     </batchtest>    
     <classpath refid="testsplus.classpath"/> 
    </junit> 

什麼是資源/ ZipEntry的部分正確的語法?

螞蟻文檔說:

batchtest任何數量的嵌套 資源集合的收集包括 資源。然後, 爲每個以.java或.class結尾的 資源生成測試類名稱。

任何類型的資源集合的被 支持作爲嵌套元素,前 到Ant 1.7只<fileset>一直 支撐。

回答

13

相反的zipentry你大概可以使用zipfileset數據類型:

<zipfileset src="tests-only.jar" includes="**/*Test.class"/> 
+0

,謝謝,我已經證實了這一工作。 – JasonPlutext

+0

適合我! – Saurabh

+0

我正面臨ClassNotFoundException,當我試圖在jar文件內運行junit時。你能找到解決這個問題的任何解決方案嗎? – Jugi