error: 'class ClassA' has no member named 'gmock_member'

7,207 views
Skip to first unread message

rkovacina

unread,
Jun 8, 2010, 3:25:54 PM6/8/10
to Google C++ Mocking Framework
Hi,

I am trying to use Google mock to create a mock object - very simple,
basic (nominal) case:

class ClassA {

virtual int member();

};

class MockClassA {
MOCK_METHOD0(member, int());
}

TEST_F()
{
:
ON_CALL(myMock, member()).WillByDefault(Return(0));

:
}

The compile fails with the mesage:
error: 'class ClassA' has no member named 'gmock_member'

What am I doing wrong?

Any help is appreciated...

Thanks.

Gabriel Schine

unread,
Jun 8, 2010, 3:56:21 PM6/8/10
to rkovacina, Google C++ Mocking Framework
class MockClassA : public ClassA {...

?

--
Gabe Schine
Google, Inc.
(650)253-0697
tha...@google.com

rkovacina

unread,
Jun 8, 2010, 4:30:04 PM6/8/10
to Google C++ Mocking Framework
Sorry, my mistake - I had that already (just forgot to add it in the
initial post)...

the problem is still there - I am comfused with 'gmock_member' in
error message ... why is it there? Is it something wrong with my gmock
setup?

thanks.
> that...@google.com- Hide quoted text -
>
> - Show quoted text -

Vlad Losev

unread,
Jun 8, 2010, 4:36:34 PM6/8/10
to Google C++ Mocking Framework
On Tue, Jun 8, 2010 at 1:30 PM, rkovacina <rkov...@gmail.com> wrote:
Sorry, my mistake - I had that already (just forgot to add it in the
initial post)...

the problem is still there - I am comfused with 'gmock_member' in
error message ... why is it there? Is it something wrong with my gmock
setup?

thanks.

On Jun 8, 3:56 pm, Gabriel Schine <that...@google.com> wrote:
> class MockClassA : public ClassA {...
>
> ?
>
>
>
>
>
> On Tue, Jun 8, 2010 at 12:25 PM, rkovacina <rkovac...@gmail.com> wrote:
> > Hi,
>
> > I am trying to use Google mock to create a mock object - very simple,
> > basic (nominal) case:
>
> > class ClassA {
>
> > virtual int member();
>
> > };
>
> > class MockClassA {
> >       MOCK_METHOD0(member, int());
> >  }
>
> > TEST_F()
> > {
> > :
> >   ON_CALL(myMock, member()).WillByDefault(Return(0));
 
myMock must be a reference to MockClassA, not ClassA.

>
> > :

> > }
>
> > The compile fails with the mesage:
> > error: 'class ClassA' has no member named 'gmock_member'
>
> > What am I doing wrong?
>
> > Any help is appreciated...
>
> > Thanks.
>
> --
> Gabe Schine
> Google, Inc.
> (650)253-0697

Sreedhar Mukkamalla

unread,
Jun 8, 2010, 4:43:25 PM6/8/10
to rkovacina, Google C++ Mocking Framework
What is the type of myMock? This error seems to indicate that the first arg
being passed to EXPECT_CALL is of type ClassA (instead of MockClassA).

An actual code snippet would be helpful (I suspect your simplified example
might be leaving out some crucial details).

Sreedhar
 

On Tue, Jun 8, 2010 at 1:30 PM, rkovacina <rkov...@gmail.com> wrote:
Reply all
Reply to author
Forward
0 new messages