开发者

Does the JUnit XML format really not have an error element?

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 nam开发者_JS百科e="name">
      <error>Some error message</error>
    </testcase>
  </testsuite>
</testsuites>


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜