0-2 gtest run flow

这篇博客详细解析了gtest的运行流程,从RUN_ALL_TESTS入口开始,深入到UnitTest.Run、RunAllTests、TestCase.Run、TestInfo.Run和Test.Run等关键步骤。在执行过程中,包括了预处理FLAG、设置和清理Environment、执行TestCase的SetUp和TearDown,以及每个Test的构建、执行和销毁。总结了Environment对象、TestCase和Test实例的生命周期及其方法调用顺序。
摘要由CSDN通过智能技术生成

博客迁移已迁移到https://www.guyuemeng.com

概述

本文主要通过示例代码,描述gtest调用的过程

测试代码结构

1.代码包含结构

  • Environment
  • TestFixture1(Test: NoName, Test: WithName)
  • TestFixture2(Test: NoName)
  • TEST

2.操作打印结果(entered…/leaving…)

Running main() from gmock_main.cc
Environment construct entered...                                
[==========] Running 4 tests from 3 test cases.
[----------] Global test environment set-up.                    
Environment SetUp entered...                                    0-- Run Environment SetUp
[----------] 1 test from TestNoFixture
[ RUN      ] TestNoFixture.NoName
TEST TestNoFixture
[       OK ] TestNoFixture.NoName (0 ms)
[----------] 1 test from TestNoFixture (0 ms total)

[----------] 2 tests from TestFixture1
TestFixture1 SetUpTestCase entered...                           1-- Run TestFixture1 SetUpTestCase
[ RUN      ] TestFixture1.NoName
TestFixture1 construct entered...                               2-- Run TestFixture1 constract
TestFixture1 SetUp entered...                                   3-- Run TestFixture1 SetUp
TEST TestFixture1 NoName
TestFixture1 TearDown leaving...                                3-- End TestFixture1 TearDown
TestFixture1 destruct leaving...                                2-- End TestFixture1 destract
[       OK ] TestFixture1.NoName (0 ms)
[ RUN      ] TestFixture1.WithName
TestFixture1 construct entered...                               2-- Run TestFixture1 constract
TestFixture1 SetUp entered...                                   3-- Run TestFixture1 SetUp
TEST TestFixture1 WithName
TestFixture1 TearDown leaving...                                3-- End TestFixture1 TearDown
TestFixture1 des
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值