I have a virtual function defined in the class which is set as MOCK_METHOD
inside the mock class.
Is it possible to override the MOCK_METHOD
to change the details of the function?
For example, SomeFunction
is what I described above, and here the return value is merely set
TEST_F(UnitTest, Test)
{
EXPECT_CALL(*classObject, SomeFunction()).
WillOnce(Return(true));
}
Rather than merely setting its return to some bool, could I modify the function itself within this unit test? So like say invoke a method of classObject
that returns a bool?
After looking into it, Invoke
is something that could be used however upon trying the following, I am getting the error Call to non-static function without an object argument
.
TEST_F(UnitTest, Test)
{
EXPECT_CALL(*classObject, SomeFunction()).
WillOnce(Invoke(classObject,
&ClassObject::SomeClassObjectMethod()));
}