如何关闭 CPPUnit 中的单元测试
我(最后)使用 CPPUnit 对我的应用程序进行单元测试,并且使用 CruiseControl.NET 运行测试并显示测试输出。然而,我有几个测试总是失败,因此 CruiseControl 总是将构建标记为失败。有什么方法可以“关闭”或“跳过”或“忽略”这些总是失败的测试吗?我宁愿不只是在源代码中注释掉它们,因为它们指出了应用程序中的有效错误,我们目前因业务原因无法修复这些错误,但可能能够在未来的版本中解决。如果可能的话,我希望仍然能够运行测试并查看它们的输出,但只是让 CPPUnit 不将它们计为失败(或者甚至可能在 CruiseControl 级别忽略它们)。
I (finally) have my app being unit tested with CPPUnit and I have CruiseControl.NET running the tests and displaying the test output. I have several tests that always fail, however, so CruiseControl always marks the build as failed. Is there any way I can "turn off" or "skip" or "ignore" these always-failing tests? I'd rather not just comment them out in the source, since they're pointing out valid errors in the app that we can't fix for business reasons at present, but may be able to address in a future release. If possible, I'd like to be able to still run the tests and see their output, but just have CPPUnit not count them as failed (or maybe even ignore them at the CruiseControl level).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
正如 cppunit 说明书中的演示,您可以将测试组织为 test套房。我会将“已知失败”的测试放在单独的测试套件中。然后,您可以选择何时运行此测试套件以及何时忽略它。
As demonstrated in the cppunit cookbook, you can organize your tests into test suites. I would put the "known to fail" tests in a separate test suite. You can then chose when to run this test suite and when to ignore it.
您好,
您不能注释掉 testSuite_* 代码中的各个测试吗?
编辑:抱歉,我没有完全解析您的问题。但是 testSuite_ 是一种对以某种方式相关的各个测试进行分组的方法,例如,对于我们正在使用的 LD_PRELOAD 重新映射库,我们有多个测试套件,例如,
将多个测试分组在一起以执行特定的操作系统命令。
但想一想,实际上阅读你所说的(-:,你似乎想要保持 CPPUnit 的功能正常工作而不是使用它,即仍然将测试标记为失败。
所以我建议考虑使用 CruiseControl 的行为来忽略那些已知的故障,甚至可能暂时将它们标记为“可接受”,例如构建的琥珀色状态,而不是绿色或红色状态,这两种状态都是错误的。 。
CruiseControl 是非常可配置的,并且在他们的 wiki 上有一个活跃的社区,可以通过他们的 home 访问 抱歉,
HTH
除了建议您修改 CruiseControl 行为而不是使用 CPPUnit 之外,我无法提供更具体的信息。
G'day,
Aren't you able to comment out the individual tests in the testSuite_* code?
Edit: Sorry, I didn't fully parse your question. But a testSuite_ is a way of grouping individual tests that are related in some way, e.g. for an LD_PRELOAD remapping library that we're using we have several test suites, e.g.
that group several tests together that exercise that particular OS command.
But having a think about it, and actually reading what you said (-: , you seem to want to keep the functionality of CPPUnit working and not play with it, i.e. still flagging tests as failing.
So I'd suggest looking at playing with the behaviour of CruiseControl to ignore those known failures. Maybe even flag them as "acceptable" for the time being, e.g. an amber status for the build rather than a green or red status both of which are false for the circumstances you describe.
CruiseControl is very configurable and there is an active community for it over at their wiki which is accessible via their home page.
HTH
Sorry I can't be more specific apart from recommending that you modify CruiseControl behaviour rather than play with CPPUnit.