簡體   English   中英

Junit + Ant + Eclipse單元測試嘗試運行,但始終返回1執行

[英]Junit + Ant + Eclipse unit test attempts to run but always returns 1 execution

我有一個通過Eclipse運行的ant任務,無法正確執行測試用例。 Ant的輸出如下:

[junit] Running my.custom.test.GoTest   
[junit] Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 0 seconds   
[junit] Test my.custom.test.GoTest FAILED

最小可能的Ant腳本:

<project>
    <target name="test">  
      <javac srcdir="Test/src" destdir="Test/bin" />  
      <junit fork="true" printsummary="true">  
          <batchtest>   
             <fileset dir="Test/test">  
                 <include name="**/*Test.*"/>  
             </fileset> 
          </batchtest>  
      </junit>  
    </target>  
</project>

Java文件:

package my.custom.test  

public class GoTest  
{  
     @Test
     public void test_1() throws Exception  
     {  
         assertTrue(true);  
     }    
     @Test
     public void test_2() throws Exception  
     {  
         assertFalse(false);  
     } 
}  

我希望以上來自ant junit任務的輸出產生正在運行的兩個測試。 但是,只有一個正在運行。 我正在尋找有關發生這種情況的任何原因,或者是否缺少我遇到的配置問題。

如果其他人遇到了完全相同的問題或非常相似的問題,則以下更改將大有裨益:

<junit fork="true" printsummary="true">    
          <formatter type="plain" usefile="false" />
          <batchtest>   
             <fileset dir="Test/test">  
                 <include name="**/*Test.*"/>  
             </fileset> 
          </batchtest>  
</junit>  

這導致我一個ClassNotFoundException

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM