I have several unit test cases, which I have written with the Google Test framework:
Test class:
class Test: public testing::Test
{
public:
virtual void SetUp() {}
virtual void TearDown() {}
};
Actual tests:
TEST_F(Test, SubTest1)
{
// execute Test logic
}
TEST_F(Test, SubTest2)
{
// execute Test logic
}
TEST_F(Test, SubTest3)
{
// execute Test logic
}
Assumed that I want to display only
SubTest1
andSubTest3
, what do I have to do? Important is, that I want to see at a central place (main method), which tests are actually executed.
I thought, that I can "stack" filters as in the following example, but this approach did not work:
int main(int argc, char** argv)
{
::testing::InitGoogleMock(&argc, argv);
::testing::GTEST_FLAG(filter) = "Test.SubTest1";
::testing::GTEST_FLAG(filter) = "Test.SubTest3";
return RUN_ALL_TESTS();
}
→ The second filter removed the first one and only SubTest3
is executed.
I tried to find some official googletest
reference, but I only found this article explaining the syntax of googletest filters. If you want to run testcases matching one of 2 different patterns, your filter should look like:
"FIRST_PATTERN:SECOND_PATTERN"
So, in your case:
::testing::GTEST_FLAG(filter) = "Test.SubTest1:Test.SubTest3";
You can also use wilcards ?
and *
and you can add exclusion patterns after -
sign.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With