Uninteresting mock function call

16,163 views
Skip to first unread message

Richard Johnson

unread,
Mar 13, 2013, 11:40:00 AM3/13/13
to googl...@googlegroups.com
Hello Group,

The rest of the error message is, "The mock function has no default action set, and its return type has no default value set."

I am a complete noob wrt Google Mock.  I have searched existing posts looking for the terms "uninteresting" and "default action".  Both searches have gotten me close to an answer, but I still have no solution.

There are two parts to my question:

First, I want to know why gmock considers the call "uninteresting".  In my MockSomeObj class, derived from the SomeObj class, I have defined a public MOCK_METHOD:

    MOCK_METHOD2(ObjMethod, ReturnType(ParamType1, ParamType2);

In my TEST_F(), I have 

    EXPECT_CALL(myObj, ObjMethod(ParamType1 var1, ParamType2 var2)).Times(1);

    EXPECT_EQ(ExpectedReturnTypeValue, MyTest.MethodExpectingObjMethodCalledOn_myObj(var1, var2);

My understanding of gmock is that a method named in the EXPECT_CALL macro should make the call "interesting," since I am interested enough to use the EXPECT_CALL macro.  Obviously, this is not the case, since I am receiving the error on the call to myObj.ObjMethod().

Can someone please tell me what the correct interpretation of "uninteresting mock function call" is?

Second, I believe that I have already supplied a "default action" for the method with the Times() expression.  That still did not supply a "default value," so I changed the EXPECT_CALL:

    EXPECT_CALL(myObj, ObjMethod(var1, var2)).WillOnce(Return(ExpectedReturnTypeValue));

How is it that specifying an expected return value does not supply a "default value?"

I apologize if these questions have already been answered, but I was unable to find anything specific to my issue in my searches, and applying whatever generic solutions that I found to my specific issue did not resolve it.

Thank you,

Richard F. Johnson

Tim Bochenek

unread,
Mar 14, 2013, 1:09:03 PM3/14/13
to googl...@googlegroups.com
A very common reason for this to happen is that if the function being mocked is not virtual.  The framework will then call the statically bound base class method and not your derived mock.

It can also be that a parameter is not properly matched, especially if you have a function with a default value for one or more parameters.
Reply all
Reply to author
Forward
0 new messages