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

相关文章

前端知识点之Javascript选择输入框confirm用法

《前端知识点之Javascript选择输入框confirm用法》:本文主要介绍JavaScript中的confirm方法的基本用法、功能特点、注意事项及常见用途,文中通过代码介绍的非常详细,对大家... 目录1. 基本用法2. 功能特点①阻塞行为:confirm 对话框会阻塞脚本的执行,直到用户作出选择。②

JavaScript中的reduce方法执行过程、使用场景及进阶用法

《JavaScript中的reduce方法执行过程、使用场景及进阶用法》:本文主要介绍JavaScript中的reduce方法执行过程、使用场景及进阶用法的相关资料,reduce是JavaScri... 目录1. 什么是reduce2. reduce语法2.1 语法2.2 参数说明3. reduce执行过程

在MySQL执行UPDATE语句时遇到的错误1175的解决方案

《在MySQL执行UPDATE语句时遇到的错误1175的解决方案》MySQL安全更新模式(SafeUpdateMode)限制了UPDATE和DELETE操作,要求使用WHERE子句时必须基于主键或索引... mysql 中遇到的 Error Code: 1175 是由于启用了 安全更新模式(Safe Upd

Spring Boot 整合 ShedLock 处理定时任务重复执行的问题小结

《SpringBoot整合ShedLock处理定时任务重复执行的问题小结》ShedLock是解决分布式系统中定时任务重复执行问题的Java库,通过在数据库中加锁,确保只有一个节点在指定时间执行... 目录前言什么是 ShedLock?ShedLock 的工作原理:定时任务重复执行China编程的问题使用 Shed

详解如何在React中执行条件渲染

《详解如何在React中执行条件渲染》在现代Web开发中,React作为一种流行的JavaScript库,为开发者提供了一种高效构建用户界面的方式,条件渲染是React中的一个关键概念,本文将深入探讨... 目录引言什么是条件渲染?基础示例使用逻辑与运算符(&&)使用条件语句列表中的条件渲染总结引言在现代

Python 中 requests 与 aiohttp 在实际项目中的选择策略详解

《Python中requests与aiohttp在实际项目中的选择策略详解》本文主要介绍了Python爬虫开发中常用的两个库requests和aiohttp的使用方法及其区别,通过实际项目案... 目录一、requests 库二、aiohttp 库三、requests 和 aiohttp 的比较四、requ

el-select下拉选择缓存的实现

《el-select下拉选择缓存的实现》本文主要介绍了在使用el-select实现下拉选择缓存时遇到的问题及解决方案,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的... 目录项目场景:问题描述解决方案:项目场景:从左侧列表中选取字段填入右侧下拉多选框,用户可以对右侧

如何使用 Bash 脚本中的time命令来统计命令执行时间(中英双语)

《如何使用Bash脚本中的time命令来统计命令执行时间(中英双语)》本文介绍了如何在Bash脚本中使用`time`命令来测量命令执行时间,包括`real`、`user`和`sys`三个时间指标,... 使用 Bash 脚本中的 time 命令来统计命令执行时间在日常的开发和运维过程中,性能监控和优化是不

Mybatis拦截器如何实现数据权限过滤

《Mybatis拦截器如何实现数据权限过滤》本文介绍了MyBatis拦截器的使用,通过实现Interceptor接口对SQL进行处理,实现数据权限过滤功能,通过在本地线程变量中存储数据权限相关信息,并... 目录背景基础知识MyBATis 拦截器介绍代码实战总结背景现在的项目负责人去年年底离职,导致前期规

C#如何优雅地取消进程的执行之Cancellation详解

《C#如何优雅地取消进程的执行之Cancellation详解》本文介绍了.NET框架中的取消协作模型,包括CancellationToken的使用、取消请求的发送和接收、以及如何处理取消事件... 目录概述与取消线程相关的类型代码举例操作取消vs对象取消监听并响应取消请求轮询监听通过回调注册进行监听使用Wa