博客迁移已迁移到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