Let's say we have the following classes A
and B
:
class A
{
virtual void Init() { DoSomething(); }
};
class B : public A
{
virtual void Init() { DoSomethingSpecial(); A::Init(); }
};
In our unit test we only want to test B
, that is to test using Hippomocks that calling B::Init()
will actually call DoSomethingSpecial()
:
B* b_p = new B();
m_mockRepository_p->ExpectCall(b_p, DoSomethingSpecial);
b_p->Init();
Now we don't want to expect all calls from A
's Init()
so we'd like to write something like:
m_mockRepository_p->ExpectCall(b_p, A::Init);
The last expectation causes an unhandled exception which I think is okay since we are mixing the method we're calling with its base version we want to expect. Casting b_p
to an A
doesn't help.
Is there any solution to that particular use case?