当前位置:网站首页>gtest从一无所知到熟练使用(4)如何用gtest写单元测试
gtest从一无所知到熟练使用(4)如何用gtest写单元测试
2022-07-04 20:48:00 【奇妙之二进制】
1 gtest是什么
gtest是Google开发的一个跨平台开源单元测试框架,git仓库点击这里获取。主要针对c/c++,gtest有如下特点:
测试框架
自动收集测试用例,无需开发者再次组织
提供强大的断言集,支持包括布尔、整型、浮点型、字符串等
提供断言方法自定义扩展
提供死亡测试功能
可以将公共的用例初始化和清理工作放入测试夹具中,由gtest自动调用
Value-parameterized tests.
Type-parameterized tests.
生成xml格式测试报告
2.定义一个最基本的测试用例
TEST宏用于定义一个测试用例:
#include <gtest/gtest.h>
int Add(int i
边栏推荐
- 刘锦程荣获2022年度中国电商行业创新人物奖
- 杰理之增加进关机前把触摸模块关闭流程【篇】
- 如何使用ConcurrentLinkedQueue做一个缓存队列
- Flutter在 release版本,打开后随机白屏不显示内容
- Difference between ApplicationContext and beanfactory (MS)
- Jerry's ad series MIDI function description [chapter]
- Minidom module writes and parses XML
- Flutter 返回按钮的监听
- How was MP3 born?
- [buuctf.reverse] 151_ [FlareOn6]DnsChess
猜你喜欢
[C language] deep understanding of symbols
SolidWorks工程图添加材料明细表的操作
华为ensp模拟器 给路由器配置DHCP
Maidong Internet won the bid of Beijing life insurance
Stealing others' vulnerability reports and selling them into sidelines, and the vulnerability reward platform gives rise to "insiders"
At the right time, the Guangzhou station of the city chain science and Technology Strategy Summit was successfully held
IIC (STM32)
Daily question-leetcode556-next larger element iii-string-double pointer-next_ permutation
Lambdaquerywrapper usage
How to use concurrentlinkedqueue as a cache queue
随机推荐
Jerry's ad series MIDI function description [chapter]
How was MP3 born?
Stealing others' vulnerability reports and selling them into sidelines, and the vulnerability reward platform gives rise to "insiders"
杰理之AD 系列 MIDI 功能说明【篇】
minidom 模块写入和解析 XML
杰理之AD 系列 MIDI 功能说明【篇】
Open3D 曲面法向量计算
OMS系统实战的三两事
CAD中能显示打印不显示
创客思维在高等教育中的启迪作用
Kubedm initialization error: [error cri]: container runtime is not running
The video sound of station B is very low - solution
应用实践 | 蜀海供应链基于 Apache Doris 的数据中台建设
Can be displayed in CAD but not displayed in print
Jerry's ad series MIDI function description [chapter]
Interpreting the development of various intelligent organizations in maker Education
Flutter WebView示例
杰理之AD 系列 MIDI 功能说明【篇】
更强的 JsonPath 兼容性及性能测试之2022版(Snack3,Fastjson2,jayway.jsonpath)
Use of redis publish subscription