I am unit testing a derived class and want to EXPECT_CALL that a certain method belonging to its base class is called.
For example:
class Base { public: void move(int x, int y); }; class Derived: public Base{ public: RESULT update(); private: int age; }; HRESULT Derived::update(void) { int param1 = 5, param2 = 10; move(param1, param2); age++; return SUCCESS; } I can't just create a mock for Derived and expect move since there is no dependency and the actual move() will be called.
How can I be able to mock move()? My end goal is that I need to expect move() to be called with CORRECT parameter values (param1 and param2 in this case).
Of course this isn't the actual code but just a representation
I know this is not good design as far as UT is concerned, but this is to test some legacy code I am not allowed to reformat (but need to make UT). So being able to mock and test move() is the best option I have really.
Help will be appreciated. Thanks!
Derivedclass respect? For each of its usage, what are the pre- and post-conditions? Your role, as a unit tester, is to check that for any input, if the pre-conditions are respected,Derivedrespects the post-conditions.movevirtual(for UT)?