GoogleTest运行特定的测试用例
通常GoogleTest的单元测试,直接执行,就全跑一遍,很耗时,有时候需要只测试某个case,怎么只运行某个测试用例呢?
先列出所有case:
D:\my_workspace\build\Debug>hello_test.exe --gtest_list_tests
Running main() from D:\my_workspace\build\_deps\googletest-src\googletest\src\gtest_main.cc
HelloTest.MyTestMyTest2
FactorialTest.NegativeZeroPositive
IsPrimeTest.NegativeTrivial
然后执行特定case:
hello_test.exe --gtest_filter="HelloTest*"
或者:
hello_test.exe --gtest_filter="HelloTest.MyTest2"
如果你的测试程序加这些后缀无效,可能是你的main函数写错了,把main函数删除,GoogleTest默认有main函数的,可以编译过。
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!
