Skip to content
This repository was archived by the owner on Jul 17, 2019. It is now read-only.
This repository was archived by the owner on Jul 17, 2019. It is now read-only.

Gmock test fails(should pass?) #209

@Cantafford

Description

@Cantafford

Hello,

I just started using Gtest/Gmocks and I'm struggling with an example. I have a simple class which has a member a function that returns a value(say 3). I'm trying to mock this test and check if the returned result is 3. For simplicity I wrote everything in a single file:

#include "stdafx.h"
#include "gmock\gmock.h"
#include "gtest\gtest.h"
using ::testing::AtLeast;
using namespace std;

class MyClass{
public:
virtual int retValue() { return 3; }
virtual ~MyClass(){}
};

class FakeMyClass : public MyClass
{
public:
MOCK_METHOD0( retValue, int() );
};

TEST(TestForMyClass, TestRetVal)
{
FakeMyClass obj3;
EXPECT_EQ(obj3.retValue(), 3);
}

int _tmain(int argc, _TCHAR* argv[])
{
::testing::InitGoogleMock(&argc, argv);
return RUN_ALL_TESTS();
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions