我想为尚未实现的功能添加一个测试用例,并将此测试用例标记为“没关系,我失败了”。
有办法吗?
编辑: 我希望执行测试,只要测试用例处于“预期失败”状态,框架就应该验证它是否失败。
编辑2: 好像我感兴趣的功能在google-test中不存在,但是the Boost Unit Test Framework中确实存在,并在 LIT .
最佳答案
EXPECT_NONFATAL_FAILURE 是您希望将预期失败的代码包装起来的内容。请注意,您必须包含 gtest-spi.h 头文件:
#include "gtest-spi.h"
// ...
TEST_F( testclass, testname )
{
EXPECT_NONFATAL_FAILURE(
// your code here, or just call:
FAIL()
,"Some optional text that would be associated with"
" the particular failure you were expecting, if you"
" wanted to be sure to catch the correct failure mode" );
}
关于c++ - 如何将 Google Test 测试用例标记为 "expected to fail"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20785939/