2012-07-10 71 views
1

我有一个ant任务,通过Eclipse运行,无法正确执行测试用例。从蚂蚁的输出如下:Junit + Ant + Eclipse单元测试尝试运行,但始终返回1执行

[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); 
    } 
} 

我期望从蚂蚁junit任务上面的输出产生两个测试正在运行。但是,只有一个正在运行。我正在寻找任何推理,为什么会发生这种情况,或者是否有我缺少的配置问题。

回答

1

万一别人运行到这个完全一样的问题,或者非常类似下面的变化将是大有裨益:

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

这使我一个ClassNotFoundException

+0

这是调试的好方法: D错误:1,看起来像是发生了不好的事情 – oers 2012-07-10 19:01:04

相关问题