Search code examples
c++visual-studio-2010googletestgooglemock

How to unregister a testcase and how to register a particular test case into Gtest


in gtets as we know, the moment control finds TEST or TEST_F function, it registers the test cases into gtest. But according to my requirement, after gtest registers all the testcases I need to search whether the testcasename is there in the list or not? If the tesetcasename is there then I need to unregister all the test cases and register only the found testcasename. How to do that??? Suppose

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

Suppose I am searching for "testcasename3" in the registered testcasename. and it's available. Now I want gtest to execute only the found testcase not all...

How to do that?

Any answer is appreciated


Solution

  • This can be done using the command line as described in the advanced guide, so

    ./foo_test --gtest_filter=testcasename3.*
    

    would only run testcasename3 and all its tests. The commandline syntax is extensive, tests and be included and excluded using wildcards. See the advanced documentation for more information