gTest支持的命令行参数 |
|
--gtest-filter=[filter] |
对执行的测试案例进行过滤,支持 |
--gtest_repeat=[COUNT] |
设置案例重复运行次数. 比如: |
--gtest_print_time |
打印每个测试方法运行的所用时间. |
--gtest_catch_exceptions |
捕捉异常. 这样当测试方法中抛出了异常时, 不会阻碍了后续测试方法的运行. 注意: 这个参数只在Windows下有效. |
--gtest_output=xml[:DIRECTORY_PATH/|:FILE_PATH] |
产生XML格式的报告。 |
gTest支持的断言 |
|
断言真伪 |
ASSERT_TRUE(condition) [<< message]; |
断言比较关系 |
ASSERT_EQ(expected, actual) [<< message]; |
断言C字符串关系 |
ASSERT_STREQ(expected_cstr, actual_cstr) [<< message]; |
断言异常 |
ASSERT_THROW({ statements }, exception_ctor); |
HippoMocks用于动态stub生成 |
|
准备工作 |
// In [ClassUnderTest]Test.cpp file. |
指定返回值 |
// We don't care about the passed-in arguments for CollaboratorService::methodName(). |
指定抛出异常 |
// We don't care about the passed-in arguments for CollaboratorService::methodName(). |