是否可以自定义 NUnit XML 输出?
我现在正在查看 NUnit XML 输出,想知道是否可以仅针对失败生成输出。
我的意思是,如果测试顺利通过,则根本不会为其生成 XML 输出。
XSLT 在这里不是一个选项。 我根本不需要通过的测试的 XML 输出:如果我不需要有关通过的测试的详细信息,我不希望系统花时间生成这些详细信息。*
这个想法也就是说,如果您有大量测试,XML 输出往往会相当大,但无论如何,80% 的时间您都会失败。对于这种情况,我希望以仅生成有关故障的信息的方式运行测试。
I'm looking at NUnit XML output right now and wonder if it's possible to generate the output for failures only.
I mean, if a test passes OK, no XML output gets generated for it at all.
XSLT is not an option here. I don't want XML output for passed tests at all: if I don't need the details about the passed tests, I don't want the system to spend time generating those details.*
The idea is, XML output tend to be quite large if you have a lot of tests, but 80% of the time you're after failures anyway. For such cases, I'd like to run my tests in such a way that only information on failures get generated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以在运行 NUnit console runner< 时指定 XSLT 文件/a> 自定义生成的文件:
默认 XML 文件是使用 生成的这个 XSLT 文件可以轻松修改以仅报告失败。
You can specify an XSLT file when you run the NUnit console runner to customise the generated file:
The default XML file is generated using this XSLT file which can be easily modified to report only failures.
我将此问题发布到 NUnit Google 网上论坛群组和 Charlie Poole 确认没有这样的选项。
I posted this question to the NUnit Google Groups group, and Charlie Poole confirmed that there's no such option.
我不能保证它是否有效,但也许你可以编写自己的插件来实现你想要的。
如果您使用外接程序连接到扩展点“EventListeners”,则每当测试完成时,您必须实现的方法 TestFinished(TestResult tr) 就会被调用。只需读出结果并将属性 WriteResultEntry 设置为 true(仅对于失败的测试)。
好吧,我不确定 Charlie 是否已实现后一个属性,但如果没有,您的插件仍然可以为失败的测试创建您自己的 NUnit 结果文件。
如果没有这样的属性 WriteResultEntry,请让 Charlie 实现它,或者仅在 result.IsFailure 为 true 时写入输出来创建您自己的结果报告。
I cannot guarantee if it works, but possibly you can write your own addin to achieve what you want.
If you hook into the extension point "EventListeners" with your addin, your method TestFinished(TestResult tr) which you'll have to implement will get called whenever a test is finished. Just readout the result and set the property WriteResultEntry to true only for failed tests.
Well, I'm not sure if Charlie has implemented the latter property, but if not, your addin could still create your own NUnit resultfile just for the failed tests.
If there's no such property WriteResultEntry, ask Charlie to implement it or create your own result report by only writing output when result.IsFailure is true.