I have,
class CFoo : public CFooPar
{
public:
CFoo(){}
~CFoo(){}
virtual bool ret() const
{
return true;
}
};
How can I create mock class for this virtual bool ret() const method?
Thank you!
I use Google Mock for that (https://code.google.com/p/googlemock/wiki/V1_6_ForDummies).
With that tool, the mock reads
#include "gmock/gmock.h"
class MockCFoo : public CFoo {
public:
MOCK_CONST_METHOD0(ret, bool());
};
If you mean using turtle here it is :
#include <turtle/mock.hpp>
MOCK_BASE_CLASS( MockCFoo, CFoo )
{
MOCK_METHOD( ret, 0 )
};
The rest depends on how you use CFoo in your production code, however it would likely be similar to the turtle motivation case I suppose.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With