使用TEST CASE
TEST() and TEST_F() implicitly register their tests with googletest. So, unlike with many other C++ testing frameworks, you don’t have to re-list all your defined tests in order to run them.
TEST()和TEST_F() 用GoogleTest隐式注册它们的测试。因此,与许多其他C++测试框架不同,您不必重新列出所有定义的测试以便运行它们。
After defining your tests, you can run them with RUN_ALL_TESTS() , which returns 0 if all the tests are successful, or 1 otherwise. Note that RUN_ALL_TESTS() runs all tests in your link unit – they can be from different test cases, or even different source files.
定义测试后,可以使用RUN_ALL_TESTS() 运行它们,如果所有测试都成功,则返回0,否则返回1。
请注意,RUN_ALL_TESTS() 运行链接单元中的所有测试——它们可以来自不同的测试用例,甚至是不同的源文件。
When invoked, the RUN_ALL_TESTS() macro:
当使用RUN_ALL_TESTS() 时, 以下过程会被执行:
-
Saves the state of all googletest flags
保存所有Google