How can I control when my gmock is verified?

4.9k views Asked by At

Using 'another test framework' (Qt), I want to control when the google mocks are verified:

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

     system_under_test.bar();

     //VERIFY_EXPECTATIONS(mock)
 }

But I don't find anything about that in the Cookbook.

1

There are 1 answers

0
Martin G On BEST ANSWER

This is what i normally do in similar situations:

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

    Mock::VerifyAndClearExpectations(&mock);
}

Reference: https://github.com/google/googletest/blob/master/docs/gmock_cheat_sheet.md#verifying-and-resetting-a-mock

edit: fixed broken link

2nd edit: fixed broken link again