如何控制我的gmock验证?

时间:2014-11-12 10:06:48

标签: c++ qt gmock qtestlib

使用另一个测试框架' (Qt),我想控制谷歌模拟验证的时间:

void MyQtTest::test_ThisAndThat() {
     MyMock mock;
     EXPECT_CALL(mock, foo(1));

     system_under_test.bar();

     //VERIFY_EXPECTATIONS(mock)
 }

但我在Cookbook中找不到任何相关内容。

1 个答案:

答案 0 :(得分:3)

这是我在类似情况下通常做的事情:

void MyQtTest::test_ThisAndThat()
{
    MyMock mock;
    EXPECT_CALL(mock, foo(1));
    system_under_test.bar();

    Mock::VerifyAndClearExpectations(&mock);
}

参考: https://github.com/google/googletest/blob/master/googlemock/docs/CheatSheet.md#verifying-and-resetting-a-mock