c++ - 如何注销测试用例以及如何将特定测试用例注册到 Gtest

标签 c++ visual-studio-2010 googletest googlemock

在我们所知的 gtets 中,当控件找到 TESTTEST_F 函数时,它会注册 测试用例 进入 gtest。但是按照我的要求,gtest注册完所有的测试用例之后 我需要搜索 testcasename 是否在列表中? 如果 tesetcasename 在那里,那么我需要注销所有测试用例并只注册 找到的 testcasename。 怎么做??? 假设

TEST_F(testcasename, testname){}
TEST_F(testcasename1, testname1){}
TEST_F(testcasename3, testname3){}
..
..
TEST_F(testcasenameN, testnameN){}

假设我在 registered testcasename 中搜索 "testcasename3"。它是可用的。 现在我希望 gtest 只执行找到的测试用例而不是所有...

怎么做?

欢迎回答

最佳答案

这可以使用高级指南中描述的命令行来完成,所以

./foo_test --gtest_filter=testcasename3.*

只会运行 testcasename3 及其所有测试。命令行语法很广泛,可以使用通配符进行测试和包含和排除。查看advanced documentation了解更多信息

关于c++ - 如何注销测试用例以及如何将特定测试用例注册到 Gtest,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14437098/

相关文章:

C++11 : cin doesn't wait for user input and ends the loop

c++ - QToolBar 背景颜色仅适用于操作

c++ - 避免使用 Google Mock 调用基类

c++ - expect_call,如何使用参数右值引用调用回调函数?

c++ - 自引用类型

c++ - 指向 map 的指针

c++ - 不同计算机上缺少 Visual C++ .dll

visual-studio-2010 - VS2010 将代码窗口停靠在错误的位置

visual-studio-2010 - Visual Studio 2010 在哪里存储文件菜单的 “Recent Projects and Solutions” 项?

c++ - 如何否定 gtest assert 或 expect that 中的匹配器?