I use Google mock and want to mock the inheritance chain as follows:
class A
{
}
class B : public A
{
}
class C : public B
{
}
When layout A, I need to make fun of A1 (); when layout B, I have to mock A1 () and B1 (); when layout is C, I have to mock C1 (), B1 () and A1 ().
class MockA : public A
{
}
class MockB : public B
{
}
class MockC : public C
{
}
However, for class C, I have only a new extended function C1 () left. I did not want to scoff at all my parent method, especially when too many methods were defined. But I cannot create an instance of the mockC class if I did not make fun of all the methods inherited from its parent.
, mockC C, mockB. C, mockB pure B., C- > B- > A , .
class C : public virtual B
{
}
class mockB : public virtual B
{
}
class mockC: public C, public mockB
{
}
?