11

For running all the tests under a target I use the command line command

bazel test //src/code_path:target_name

What should be additional parameters to run a test single_test from the above target?

raju
  • 4,788
  • 15
  • 64
  • 119

4 Answers4

11

On Googletest with the following setup:

TEST(TestSuite, test1)
TEST(TestSuite, test2)

you can isolate test1 using

bazel test --test_arg=--gtest_filter=TestSuite.test $TEST_TARGET_PATH

See --gtest_filter

LeafyLi
  • 126
  • 1
  • 3
3

--test_filter can be used:

For the following googletest test:

TEST(glog, log) {
  LOG(INFO) << "an INFO log message";
  VLOG(1) << "a vlog(1) message";
}

--test_filter=glog.log can be used to pick it.

Jingguo Yao
  • 7,320
  • 6
  • 50
  • 63
2

You'll want to use --test_filter:

https://docs.bazel.build/versions/2.0.0/command-line-reference.html#flag--test_filter

The specific format of the value to the flag depends on the test runner.

ahumesky
  • 4,203
  • 8
  • 12
0

To give a specific example for the default C++ testrunner (not the general "depends on which test runner you use"):

For a test:

TEST_F(HiMomFixture, testCall)
{
  EXPECT_EQ(..)
}

select this with

bazel test ... --test_filter HiMom*
or
bazel test ... --test_filter Hi*

ref @ahumesky answer below

FDS
  • 4,999
  • 2
  • 22
  • 13