Assertion text could use better indicator of being such.

63 views
Skip to first unread message

ovz

unread,
Mar 3, 2010, 10:01:16 AM3/3/10
to Google C++ Mocking Framework
Hi,

I've just spent some time figuring out the following error message

: error: Uninteresting mock function call - returning default value.
Function call: get_rootElementName()
The mock function has no default action set, and its return type
has no defa
ult value set.


": error:" prefix is not the warning about Uninteresting function
documentation promises us, but it is less than obvious from the
message that first two lines should be skipped and the text "The mock
function has no default action ..." is the problem to address. If
"uniteresting funciton" part cannot be printed outside ": error:"
prefixed text it would be good to have something like "Assertion
failed" before actual text that describes the failure. That would save
some time at least for noobs like myself.

Otherwise I like the tool so far.

Thanks.

Keith Ray

unread,
Mar 13, 2013, 11:30:55 AM3/13/13
to googlemock@googlegroups.com Framework, Richard Johnson
from the Google Mock for C++ wiki:


Setting Default Actions

Google Mock has a built-in default action for any function that returns voidbool, a numeric value, or a pointer.

To customize the default action for functions with return type T globally:

using ::testing::DefaultValue;

DefaultValue<T>::Set(value);  // Sets the default value to be returned.
// ... use the mocks ...
DefaultValue<T>::Clear();     // Resets the default value.

To customize the default action for a particular method, use ON_CALL():

ON_CALL(mock_object, method(matchers))
   
.With(multi_argument_matcher)  ?
   
.WillByDefault(action);


On 2013 Mar 13, at 7:51 AM, Richard Johnson <rfj...@gmail.com> wrote:

Hello,

I know that it has been over three years since your post, but if you are still active in the group, I would appreciate knowing how you resolved "The mock function has no default action set" issue.  I am seeing the same issue on my first attempt at mocking.

I thought that  the EXPECT_CALL macro would tell gmock that I AM interested in that call.  I have tried each of the following; both return the same error.

EXPECT_CALL(myObject, MethodName(pAbsCmd, nErrorCode)).Times(1);
EXPECT_CALL(myObject, MethodName(pAbsCmd, nErrorCode)).WillOnce(Return(PositiveResponse));

Thanks in advance,

Richard F. Johnson

--
 
---
You received this message because you are subscribed to the Google Groups "Google C++ Mocking Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to googlemock+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Reply all
Reply to author
Forward
0 new messages