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

发布于 2024-12-10 08:47:13 字数 544 浏览 0 评论 0原文

查看非正式规范:来自这个问题,我注意到没有错误元素。这只是一个疏忽吗? CruiseControl 似乎从某个地方提取错误。

<testsuites>
  <testsuite name="name" errors="1" failures="0">
    <testcase name="name">
      <error>Some error message</error>
    </testcase>
  </testsuite>
</testsuites>

Looking at the informal spec at from this question, I notice that there is no element for errors. Is that just an oversight? CruiseControl seems to extract errors from somewhere.

<testsuites>
  <testsuite name="name" errors="1" failures="0">
    <testcase name="name">
      <error>Some error message</error>
    </testcase>
  </testsuite>
</testsuites>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

似梦非梦 2024-12-17 08:47:13

您可以查看这篇文章。本文修改后的示例:

<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 属性和其他属性的信息蚂蚁网站
另一个有用的链接

You can view this article. The modified sample from this 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>

You can see all messages from junit tests in console (or in report file)
You can read about printsummary, haltonfailure properties and the other ones at the ant site.
The other useful link.

唔猫 2024-12-17 08:47:13

我知道已经有一段时间了,但是,有一个错误元素,您可以区分错误和失败:

<?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>

重要的部分是 标记和 errors 属性为

I know it's been a while, but, there is an element for errors, and you can distinguish between errors and failures:

<?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>

The important part is the <error> tag and the errors attribute to <testsuite>.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文