gtest 过滤 选择部分测试用例执行

包含main函数的gtest源文件编译为可执行程序spider,使用gtest_filter命令行参数过滤case2测试用例关联的所有测试项:
./spider --gtest_filter=case2.*

CutOneVertex为测试项(TEST(tc_linked_directiongraph, CutOneVertex))
./spider --gtest_filter=*CutOneVertex

int main(int argc, char ****argv**) {
	testing::InitGoogleTest(&argc, **argv**);
    rc = RUN_ALL_TESTS();
    return rc;
}

[uxdb@localhost backend]$ ./spider --gtest_filter=tc_linked_directiongraph_5vertex_5edge_1circle.*
<<<<<<<<<<<< Running main() from spider.cc
<<<<<<<<<<<< notice - initialize uxdb master environment … done
Note: Google Test filter = tc_linked_directiongraph_5vertex_5edge_1circle.*
[==========] Running 1 test from 1 test suite.
[----------] Global test environment set-up.
[----------] 1 test from tc_linked_directiongraph_5vertex_5edge_1circle
[ RUN ] tc_linked_directiongraph_5vertex_5edge_1circle.FindPathBetweenTwoVertex

[ OK ] tc_linked_directiongraph_5vertex_5edge_1circle.FindPathBetweenTwoVertex (0 ms)
[----------] 1 test from tc_linked_directiongraph_5vertex_5edge_1circle (0 ms total)

[----------] Global test environment tear-down
[==========] 1 test from 1 test suite ran. (0 ms total)
[ PASSED ] 1 test.

其实在命令行带/?参数执行编译好的测试程序,就知道gTest这些开关:
附在下面
This program contains tests written using Google Test. You can use the
following command line flags to control its behavior:

Test Selection:
–gtest_list_tests
List the names of all tests instead of running them. The name of
TEST(Foo, Bar) is “Foo.Bar”.
gtest_filter=POSTIVE_PATTERNS[-NEGATIVE_PATTERNS]
Run only the tests whose name matches one of the positive patterns but
none of the negative patterns.
‘?’ matches any single character;
‘*’ matches any substring;
‘:’ separates two patterns.
–gtest_also_run_disabled_tests
Run all disabled tests too.

[uxdb@localhost backend]$ ./spider /?
<<<<<<<<<<<< Running main() from spider.cc
This program contains tests written using Google Test. You can use the
following command line flags to control its behavior:

Test Selection:
–gtest_list_tests
List the names of all tests instead of running them. The name of
TEST(Foo, Bar) is “Foo.Bar”.
–gtest_filter=POSTIVE_PATTERNS[-NEGATIVE_PATTERNS]
Run only the tests whose name matches one of the positive patterns but
none of the negative patterns. ‘?’ matches any single character; ‘*’
matches any substring; ‘:’ separates two patterns.
–gtest_also_run_disabled_tests
Run all disabled tests too.

Test Execution:
–gtest_repeat=[COUNT]
Run the tests repeatedly; use a negative count to repeat forever.
–gtest_shuffle
Randomize tests’ orders on every iteration.
–gtest_random_seed=[NUMBER]
Random number seed to use for shuffling test orders (between 1 and
99999, or 0 to use a seed based on the current time).

Test Output:
–gtest_color=(yes|no|auto)
Enable/disable colored output. The default is auto.
–gtest_print_time=0
Don’t print the elapsed time of each test.
–gtest_output=(json|xml)[:DIRECTORY_PATH/|:FILE_PATH]
Generate a JSON or XML report in the given directory or with the given
file name. FILE_PATH defaults to test_detail.xml.
–gtest_stream_result_to=HOST:PORT
Stream test results to the given server.

Assertion Behavior:
–gtest_death_test_style=(fast|threadsafe)
Set the default death test style.
–gtest_break_on_failure
Turn assertion failures into debugger break-points.
–gtest_throw_on_failure
Turn assertion failures into C++ exceptions for use by an external
test framework.
–gtest_catch_exceptions=0
Do not report exceptions as test failures. Instead, allow them
to crash the program or throw a pop-up (on Windows).

Except for --gtest_list_tests, you can alternatively set the corresponding
environment variable of a flag (all letters in upper-case). For example, to
disable colored text output, you can either specify --gtest_color=no or set
the GTEST_COLOR environment variable to no.

For more information, please read the Google Test documentation at
https://github.com/google/googletest/. If you find a bug in Google Test
(not one in your own code or tests), please report it to
googletestframework@googlegroups.com.
<<<<<<<<<<<< notice - initialize uxdb master environment … done
[uxdb@localhost backend]$

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值