I want to use hippomocks to mock a method in a class. That method is called by another method in the same class. As in...
class Foo {
public:
Foo() {}
virtual ~Foo() {}
virtual string getName() {
return "Joe";
}
virtual void print() {
std::cout<<"Name is "<<getName()<<std::endl;
}
};
int main() {
std::cout<<"test mocking classes()..."<<std::endl;
MockRepository mocks;
Foo* pFoo = mocks.Mock<Foo>();
mocks.ExpectCall(pFoo, Foo::getName).Return("John");
pFoo->print();
return 0;
}
test mocking classes()...
terminate called after throwing an instance of 'HippoMocks::NotImplementedException' what(): Function called without expectation!
Any idea why i can't mock a method like this?
The example on http://hippomocks.com/Main_Page looks almost the same as mine, so i think this should be supported?
Thanks, G
What I understand from how hippomocks works is that it is overriding all of the virtual functions in your class, so the exception is probably caused by calling unexpected
print()