2011-10-13 40 views

回答

1

您可以浏览这个article。从这篇文章修改后的示例:

<target name="test"> 
    <junit printsummary="withOutAndErr" fork="off" haltonfailure="no"> 
     <classpath refid="classpath.test"/> 
     <formatter type="brief" usefile="false"/> 
     <test name="packagename.MyTest"/> 
    </junit> 
</target> 

你可以看到从JUnit测试中的所有消息控制台(或报告文件) 你可以阅读有关printsummary, haltonfailure性质和其他的人在ant site
其他useful link

+1

我没有使用Ant,而是创建了一个试图兼容的脚本(CI工具),因此只需要知道标准如何处理错误。 – dromodel

0

我知道它已经有一段时间,但是,有一个错误的元素,你可以错误和失败之间的区别:

<?xml version="1.0" encoding="utf-8"?> 
<testsuites errors="1" failures="2" tests="5" time="10"> 
    <testsuite errors="1" failures="2" id="0" name="TestSuite1" tests="4" timestamp="2015-04-20T00:00:00"> 
     <testcase classname="ModuleIAmTesting" name="testDoNothingDoesNothing" time="1"/> 
     <testcase classname="ModuleIAmTesting" name="testLongThingTakesALongTime" time="5"/> 

     <testcase classname="ModuleIAmTesting" name="testSkyIsBlue" time="1"> 
      <failure message="Test testSkyIsBlue() failed!" type="failure"> 
       It's storming; sky is gray today. Failure output, details, etc. 
      </failure> 
     </testcase> 

     <testcase classname="ModuleIAmTesting" name="testIsNotStorming" time="1"> 
      <failure message="Test testIsNotStorming() failed!" type="failure"> 
       Another failure. Failure output, details, etc. 
      </failure> 
     </testcase> 

     <testcase classname="ModuleIAmTesting" name="testCreatePlugin" time="2"> 
      <error message="Error while executing test testCreatePlugin()!" type="error"> 
       Unhandled catastrophic exception in ModuleIAmTesting.cpp at like 4420, details, etc. 
      </error> 
     </testcase> 
    </testsuite> 
</testsuites> 

的重要组成部分,是<error>标签和errors属性<testsuite>