Your expectation is saying that when obj
is destroyed you expect that function to have been called one time. You are getting failures because the function is not actually being called.
TEST(Base, case1)
{
MockBase obj;
EXPECT_CALL(obj, get()).WillOnce(::testing::Return());
obj.get();
}
Would cause this case to pass. Obviously this isn't very useful, normally you would inject the mock into the object under test. Also note that the action in this case is unnecessary, the following will work.
TEST(Base, case1)
{
MockBase obj;
EXPECT_CALL(obj, get());
obj.get();
}
Google has some good references:
https://github.com/google/googletest/blob/master/googlemock/docs/for_dummies.md
https://github.com/google/googletest/blob/master/googlemock/docs/cheat_sheet.md
https://github.com/google/googletest/blob/master/googlemock/docs/cook_book.md