JUnit XML格式真的没有错误元素吗?

3
我看到从this question查看非正式规范时,注意到没有错误元素。这只是一个疏忽吗?CruiseControl似乎会从某个地方获取错误信息。
<testsuites>
  <testsuite name="name" errors="1" failures="0">
    <testcase name="name">
      <error>Some error message</error>
    </testcase>
  </testsuite>
</testsuites>
2个回答

1
您可以查看此文章。该文章中的修改示例如下:
<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测试的所有消息。 您可以在Ant网站上了解有关printsummary,haltonfailure属性和其他属性的信息。
另一个有用的链接


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>标签和<testsuite>errors属性。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接