I have a unit test I want to write in GMock. However, my familiarity is primarily with Mockito. What I would write in Mockito is:
Mockito.verify(mock, Mockito.never()).someFunctionCall(Matchers.<String>any());
doSomething(mock);
Mockito.verify(mock, Mockito.times(1)).someFunctionCall(Matchers.<String>any());
doSomethingElse(mock);
Which corresponds to verifying that doSomething
never invokes someFunctionCall
but is called exactly once by doSomethingElse
.
How would I accomplish the same thing with GMock?
EXPECT_CALL(mock, someFunctionCall(_)).Times(0);
doSomething(mock);
EXPECT_CALL(mock, someFunctionCall(_)).Times(1);
doSomethingElse(mock);
Obviously doesn't work since the expectations stack.
Mock::VerifyAndClearExpectations / Mock::VerifyAndClear can be used for these purposes.