vendredi 1 décembre 2017

GMOCK base class methods in derived class

I have a class that is inherited from another class as mentioned below:

class A
{
public:
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.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?

Aucun commentaire:

Enregistrer un commentaire