2

I need to execute only one of tests that I created. However, I didn't find how to run it, because I only found "Run_all_tests".

Kawasaki
  • 41
  • 1
  • 3

1 Answers1

9

From the gtest Advanced Guide:

By default, a Google Test program runs all tests the user has defined. Sometimes, you want to run only a subset of the tests (e.g. for debugging or quickly verifying a change). If you set the GTEST_FILTER environment variable or the --gtest_filter flag to a filter string, Google Test will only run the tests whose full names (in the form of TestCaseName.TestName) match the filter.

So for example adding the flag:

--gtest_filter=Foo.Bar

will filter and disable every single tests except Foo.Bar. Other options described in the guide give more flexibility over which tests you want to have executed at runtime.

Asics
  • 858
  • 1
  • 11
  • 20
  • Updated link to gtest advanced guide: https://google.github.io/googletest/advanced.html – A.Sha Mar 03 '23 at 19:38