简体   繁体   English

如何将测试标记为Google Test中的“不确定”?

[英]How does one mark a test as anything like “inconclusive” in Google Test?

We have a test that fails if the test suite is not run with administrator rights. 如果测试套件没有以管理员权限运行,我们的测试会失败。 This is expected behavior. 这是预期的行为。 However, we want to return something other than success from the test suite so that someone remembers to go back and try the tests again as admin. 但是,我们希望从测试套件中返回除成功之外的其他内容,以便有人记得返回并以管理员身份再次尝试测试。

Is there a way to tell Google Test that the test hasn't failed, but hasn't really succeeded either? 有没有办法告诉Google Test测试没有失败,但是还没有真正成功?

What I'd do is separate out the component into two pieces (two projects). 我要做的是将组件分成两部分(两个项目)。 The project that has the kernel driver requires admin to test, and the other project mocks it for test purposes so the test doesn't fail. 具有内核驱动程序的项目需要管理员进行测试,而另一个项目为了测试目的而对其进行模拟,因此测试不会失败。

No, I don't think there is a way to tell GoogleTest that a test has not failed, but has not passed either. 不,我认为没有办法告诉GoogleTest测试没有失败,但也没有通过。

That said, the closest is probably EXPECT, a non-fatal assertion: http://code.google.com/p/googletest/wiki/V1_6_Primer#Assertions 也就是说,最接近的可能是EXPECT,这是一个非致命的断言: http//code.google.com/p/googletest/wiki/V1_6_Primer#Assertions

The test will fail, but execution of the test function will continue, which seems to be what you want. 测试将失败,但测试功能的执行将继续,这似乎是你想要的。

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

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