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

2024-06-09 14:18

本文主要是介绍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]$

这篇关于gtest 过滤 选择部分测试用例执行的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1045414

相关文章

java敏感词过滤的实现方式

《java敏感词过滤的实现方式》文章描述了如何搭建敏感词过滤系统来防御用户生成内容中的违规、广告或恶意言论,包括引入依赖、定义敏感词类、非敏感词类、替换词类和工具类等步骤,并指出资源文件应放在src/... 目录1.引入依赖2.定义自定义敏感词类3.定义自定义非敏感类4.定义自定义替换词类5.最后定义工具类

MyBatis Plus中执行原生SQL语句方法常见方案

《MyBatisPlus中执行原生SQL语句方法常见方案》MyBatisPlus提供了多种执行原生SQL语句的方法,包括使用SqlRunner工具类、@Select注解和XML映射文件,每种方法都有... 目录 如何使用这些方法1. 使用 SqlRunner 工具类2. 使用 @Select 注解3. 使用

Linux kill正在执行的后台任务 kill进程组使用详解

《Linuxkill正在执行的后台任务kill进程组使用详解》文章介绍了两个脚本的功能和区别,以及执行这些脚本时遇到的进程管理问题,通过查看进程树、使用`kill`命令和`lsof`命令,分析了子... 目录零. 用到的命令一. 待执行的脚本二. 执行含子进程的脚本,并kill2.1 进程查看2.2 遇到的

java中ssh2执行多条命令的四种方法

《java中ssh2执行多条命令的四种方法》本文主要介绍了java中ssh2执行多条命令的四种方法,包括分号分隔、管道分隔、EOF块、脚本调用,可确保环境配置生效,提升操作效率,具有一定的参考价值,感... 目录1 使用分号隔开2 使用管道符号隔开3 使用写EOF的方式4 使用脚本的方式大家平时有没有遇到自

mybatis直接执行完整sql及踩坑解决

《mybatis直接执行完整sql及踩坑解决》MyBatis可通过select标签执行动态SQL,DQL用ListLinkedHashMap接收结果,DML用int处理,注意防御SQL注入,优先使用#... 目录myBATiFBNZQs直接执行完整sql及踩坑select语句采用count、insert、u

一个Java的main方法在JVM中的执行流程示例详解

《一个Java的main方法在JVM中的执行流程示例详解》main方法是Java程序的入口点,程序从这里开始执行,:本文主要介绍一个Java的main方法在JVM中执行流程的相关资料,文中通过代码... 目录第一阶段:加载 (Loading)第二阶段:链接 (Linking)第三阶段:初始化 (Initia

C++统计函数执行时间的最佳实践

《C++统计函数执行时间的最佳实践》在软件开发过程中,性能分析是优化程序的重要环节,了解函数的执行时间分布对于识别性能瓶颈至关重要,本文将分享一个C++函数执行时间统计工具,希望对大家有所帮助... 目录前言工具特性核心设计1. 数据结构设计2. 单例模式管理器3. RAII自动计时使用方法基本用法高级用法

Java实现远程执行Shell指令

《Java实现远程执行Shell指令》文章介绍使用JSch在SpringBoot项目中实现远程Shell操作,涵盖环境配置、依赖引入及工具类编写,详解分号和双与号执行多指令的区别... 目录软硬件环境说明编写执行Shell指令的工具类总结jsch(Java Secure Channel)是SSH2的一个纯J

python 线程池顺序执行的方法实现

《python线程池顺序执行的方法实现》在Python中,线程池默认是并发执行任务的,但若需要实现任务的顺序执行,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋... 目录方案一:强制单线程(伪顺序执行)方案二:按提交顺序获取结果方案三:任务间依赖控制方案四:队列顺序消

Go语言连接MySQL数据库执行基本的增删改查

《Go语言连接MySQL数据库执行基本的增删改查》在后端开发中,MySQL是最常用的关系型数据库之一,本文主要为大家详细介绍了如何使用Go连接MySQL数据库并执行基本的增删改查吧... 目录Go语言连接mysql数据库准备工作安装 MySQL 驱动代码实现运行结果注意事项Go语言执行基本的增删改查准备工作