简体   繁体   English

如何在CPPUnit中关闭单元测试

[英]how to turn off a unit test in CPPUnit

I (finally) have my app being unit tested with CPPUnit and I have CruiseControl.NET running the tests and displaying the test output. 我(最后)对我的应用程序进行了CPPUnit单元测试,并让CruiseControl.NET运行测试并显示测试输出。 I have several tests that always fail, however, so CruiseControl always marks the build as failed. 我有几个测试总是失败,因此,CruiseControl总是将构建标记为失败。 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). 如果可能的话,我希望仍然能够运行测试并查看其输出,但是只是让CPPUnit不将其视为失败(或者甚至在CruiseControl级别将其忽略)。

As demonstrated in the cppunit cookbook, you can organize your tests into test suites. 作为证明的CppUnit的食谱,你可以组织你的测试到测试套件。 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. 然后,您可以选择何时运行此测试套件以及何时忽略它。

G'day, 天儿真好,

Aren't you able to comment out the individual tests in the testSuite_* code? 您是否无法在testSuite_ *代码中注释掉各个测试?

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, eg for an LD_PRELOAD remapping library that we're using we have several test suites, eg 但是,testSuite_是一种对以某种方式相关的单个测试进行分组的方法,例如,对于我们正在使用的LD_PRELOAD重映射库,我们有多个测试套件,例如

testSuite_access.c
testSuite_acl.c
testSuite_chdir.c
testSuite_chmod.c
...    
etc.

that group several tests together that exercise that particular OS command. 该小组一起执行了特定的OS命令的几个测试。

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, ie still flagging tests as failing. 但是仔细考虑一下,然后实际阅读您说的内容(-:,您似乎想保持CPPUnit的功能正常运行而不使用它,即仍将测试标记为失败。

So I'd suggest looking at playing with the behaviour of CruiseControl to ignore those known failures. 因此,我建议您考虑使用CruiseControl的行为来忽略那些已知的故障。 Maybe even flag them as "acceptable" for the time being, eg 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 . CruiseControl的可配置性很强,在其wiki上有一个活跃的社区,可通过其主页访问。

HTH HTH

Sorry I can't be more specific apart from recommending that you modify CruiseControl behaviour rather than play with CPPUnit. 抱歉,除了建议您修改CruiseControl行为而不是使用CPPUnit之外,我不能更具体了。

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

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