Re: [googletest] GTEST_FLAG(filter) problem

3,226 views
Skip to first unread message

Dirk Meister

unread,
Mar 8, 2013, 9:51:12 AM3/8/13
to bri...@gmail.com, Google C++ Testing Framework
Hello,

According to the documentation [1], the ":" is a separator for different filters. If a tests passed any of the filters, it is executed.
Therefore, "*test*:**" executed all tests as "**" matches any test name.

Best regards,
Dirk



On Fri, Mar 8, 2013 at 10:48 AM, <bri...@gmail.com> wrote:
Hi, I am running googletest from Visual Studio and targeting an embedded target device.

I would like to run a limited set of tests which can be configured programmatically. I think the way to do this is through filtering. 

I have this as a basis (many different filter test string combinations have been tried). I do see the text "Note: Google Test filter = " on the console.

    ::testing::GTEST_FLAG(filter) = "*test*:**";
    testing::InitGoogleTest(&argc, argv);
    RUN_ALL_TESTS();

However, all the tests are always run.

As a test, I have also tried to set using command line -gtest_filter="*test*:*".  Again all the tests are run.

However  -gtest_filter="*zzzz*", no tests are run. And setting ::testing::GTEST_FLAG(filter) = "*zzz*"; within the program, not tests are run.

Any Suggestions? Can I get confirmation of the exact format of the filter needed and is it indeed the test_case_name and test_name defined in  TEST(test_case_name, test_name) and TEST_F(test_case_name, test_name)

Thanks.

--
 
---
You received this message because you are subscribed to the Google Groups "Google C++ Testing Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to googletestframe...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

bri...@gmail.com

unread,
Mar 13, 2013, 8:51:23 AM3/13/13
to googletes...@googlegroups.com, bri...@gmail.com
Hi Dirk,

Many thanks for the information.

I have reviewed this section. I have tried to create a filter to run just one test. I have used the command line to pass in the format --gtest_filter=TestCaseName:TestName

My application displays the correct filter to the console :-

"Note: Google Test filter = TestCaseName:TestName"

I can confirm that I have a test in the form:

TEST(TestCaseName, TestName)

However, none of my tests are executed.

Any ideas why this might be the case?

Also, I am actually using gtest inside gmock 1.6.0.

Thanks
To unsubscribe from this group and stop receiving emails from it, send an email to googletestframework+unsub...@googlegroups.com.

Dirk Meister

unread,
Mar 13, 2013, 9:11:14 AM3/13/13
to bri...@gmail.com, Google C++ Testing Framework
Hello,

Normal tests as you used are denoted as TestCaseName.TestName in gtest.
So the filter for this test should be --gtest_filter=TestCaseName.TestName.

P.S. Sometimes it helps to output the names of all tests in a binary. You can use --gtest_list_tests for this.


To unsubscribe from this group and stop receiving emails from it, send an email to googletestframe...@googlegroups.com.

bri...@gmail.com

unread,
Mar 13, 2013, 12:29:23 PM3/13/13
to googletes...@googlegroups.com, bri...@gmail.com
Hi Dirk,

Many thanks for your response. I now understand where I was was going wrong. I read the separator ":" to be the character to separate TestCaseName and TestName - it is not.

For anyone else of read, here is what can be constructed:-

::testing::GTEST_FLAG(filter) = "TestCaseOne.*:TestCaseTwo.Test5:TestCaseTen.Test3";

This will execute all tests under TestCaseOne and two extra individual tests (TestCaseTwo.Test5, TestCaseTen.Test3).

Thanks Dirk!
To unsubscribe from this group and stop receiving emails from it, send an email to googletestframework+unsubscribe...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.
 
 

Ken Turkowski

unread,
Mar 18, 2013, 4:16:56 PM3/18/13
to bri...@gmail.com, googletes...@googlegroups.com
--gtest_filter=TestCaseName.TestName

To unsubscribe from this group and stop receiving emails from it, send an email to googletestframe...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages