Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do we run a single test using Google bazel

Tags:

c++

bazel

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?

like image 601
raju Avatar asked Feb 14 '20 21:02

raju


3 Answers

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

like image 59
LeafyLi Avatar answered Oct 07 '22 09:10

LeafyLi


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.

like image 25
ahumesky Avatar answered Oct 07 '22 08:10

ahumesky


--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.

like image 23
Jingguo Yao Avatar answered Oct 07 '22 09:10

Jingguo Yao