Search code examples
c++googletestgooglemock

google mock : how can I " EXPECT " that no method will be called on a mock


I want to test that in case of some fail no method will be called on a mock object, using google mock. So the code would be something like:

auto mockObj = new MockObj;
EXPECT_NO_METHOD_CALL(mockObj); // this is what I'm looking for

auto mainObj = new MainObj(mocObj , ......and other mocks); // here I simulate a fail using the other mock objects, and I want to be sure the no methods are called on the mockObj

Solution

  • Create a StrictMock; any unexpected method call will be a failure.