1

我有一个通过 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 任务的上述输出能够产生两个正在运行的测试。但是,只有一个正在运行。我正在寻找有关为什么会发生这种情况或是否存在我遗漏的配置问题的任何推理。

4

1 回答 1

1

如果其他人遇到同样的问题或非常相似的问题,以下更改将非常有用:

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

这导致我ClassNotFoundException

于 2012-07-10T15:22:43.983 回答