I have a class that is inherited from another class as mentioned below:
class A
{
public:
virtual void Show(){}
};
class B : public A
public:
void BMethod1(){Show()}
};
Now I am writing test cases for class B - so I have mocked class A :
class MockA : public A
{
MOCK_METHOD0(Show, void());
};
Below is my Google Test framework test case:
TEST(BTEST , ShowMethod)
{
B bobj;
MockA aobj;
EXPECT_CALL(aobj , Show());
bobj.BMethod1(); // updated as from bobj.METHOD0()
}
But the test cases is calling the actual A::Show() implementation - how can call the Mocked version of MockA::Show() in such a case?
====================UPDATE=================================
Well the below implementation did the trick for me:
class A
{
public:
virtual void Show(){}
};
class B : public A
public:
void BMethod1(){Show()}
};
class BMock : public B
{
public:
MOCK_METHOD0(Show, void());
};
Now use BMock object to test you class B required methods