简体   繁体   English

即使通过测试,如何获得NUnit预期和实际结果?

[英]How to get NUnit expected and actual results, even when tests pass?

We are trying to generate automated test reports from our NUnit tests by parsing the output .xml file. 我们正在尝试通过解析输出.xml文件从NUnit测试生成自动化测试报告。

If a test fails, the output is printed: 如果测试失败,则输出:

<test-case id="1013" name="TestThatFails" fullname="TestThatFails" methodname="TestThatFails" classname="TestThatFails" runstate="Runnable" seed="921492075" result="Failed" start-time="2017-10-17 01:34:26Z" end-time="2017-10-17 01:34:33Z" duration="6.367749" asserts="1">
    <failure>
        <message><![CDATA[  Expected: 136      But was:  135    ]]>/message>
        <stack-trace><![CDATA[   *stack trace here*    ]]></stack-trace>
    </failure>
    <assertions>
        <assertion result="Failed">
            <message><![CDATA[  Expected: 136      But was:  135    ]]>/message>
            <stack-trace><![CDATA[   *stack trace here*   ]]></stack-trace>
        </assertion>
    </assertions>
</test-case>

However if the test passes, no information about the expected or actual values are written: 但是,如果测试通过,则不会写入有关预期或实际值的信息:

<test-case id="1014" name="TestThatPasses" fullname="TestThatPasses" methodname="TestThatPasses" classname="TestThatPasses" runstate="Runnable" seed="1565993596" result="Passed" start-time="2017-10-17 01:34:33Z" end-time="2017-10-17 01:34:33Z" duration="0.003047" asserts="2" />

Is there any way to get all the assertions, even if the tests pass? 即使测试通过,有没有办法获得所有的断言?

As you have seen, the way to get reports from NUnit is by reading the XML output. 如您所见,从NUnit获取报告的方法是读取XML输出。 That output contains information about assertions that failed, but not about those that succeeded. 该输出包含有关失败的断言的信息,但不包含有关成功的断言的信息。 Adding info about passing assertions would be a new feature, one we envisioned doing eventually but for which there is no current schedule. 添加有关传递断言的信息将是一项新功能,我们预想最终会执行此功能,但是目前尚无时间表。 Requesting the feature would be a good way to make it happen sooner. 请求该功能将是使其早日实现的好方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM