problem with .Times() method in google mock

720 views
Skip to first unread message

Steven

unread,
Nov 4, 2011, 12:03:38 PM11/4/11
to Google C++ Mocking Framework
Greetings,

We are having trouble with the google mock framework when calling
something similar to this:

EXPECT_CALL(object, method( _, _))
.Times(0);

So object is a mocked object and method is an overriden method in the
mock. We find that this will pass whether we call the method or not.
And If we arent calling the method and we increase the Times to 1 it
will still pass. Then we can put in whatever number we want (1000,
10000, silly values like that) and it will still pass.

Is there any resolution to this? We are running with the 1.5 dlls so
is this something that is fixed with the latest release?

Thanks,

Steven

Greg Miller

unread,
Nov 4, 2011, 12:53:49 PM11/4/11
to Steven, Google C++ Mocking Framework
Hi, Steven.

Specifying .Times(0) is the way to say that a method should not be called. Are you sure your test code is being executed? Can you provide a small repro example so we have more details about your situation?

Greg

Steven

unread,
Nov 8, 2011, 8:28:29 AM11/8/11
to Google C++ Mocking Framework
Here is some sample code here. We inject our mocked Queue class into
our Extension object. The first EXPECT_CALL returns the desired result
in arg 3. However The second expectation will pass no matter what we
put in the parameter for .Times. That is the issue we are having.

Queue = new MockQueue(NULL, "", "", 0, NULL);
Extension->SetQueue(Queue);
EXPECT_CALL(*Queue,
GetRouteInformation(StrEq("NOCHECK"),_,_,_,_,_,_,_,_))
.WillOnce(SetArgReferee<3>("UNDERTHRESHOLD"));
EXPECT_CALL(*Queue, CreateCall(_,_,_,_))
.Times(0);

Extension->Request(device, data);
> > Steven- Hide quoted text -
>
> - Show quoted text -

Vlad Losev

unread,
Nov 8, 2011, 11:50:26 AM11/8/11
to Google C++ Mocking Framework
Steven -

It's not possible to reproduce the problem with the example you provided. Can you provide a short but complete program that shows the issue?

It's even possible that you will discover the issue while trying to reduce your code to a small example.

Regards,
Vlad

mahesh gs

unread,
Oct 30, 2013, 2:52:19 AM10/30/13
to googl...@googlegroups.com
Hi,

Is there any solution to this problem . I am facing same kind of issue. I give .Times(1000)  testcase still pass.

Thanks,
Mahesh G S
Reply all
Reply to author
Forward
0 new messages