Suppose I have the following mock
enum class State
{
IDLE,
BUSY,
ERROR1,
ERROR2
};
class MockActuator : public ActuatorInterface
{
public:
MOCK_METHOD0(doAction, void());
MOCK_METHOD0(getState, State());
};
The module I am testing makes the assumption that if doAction() is called, getState() should return BUSY.
How do I encode this assumption under GMock? I would like to keep getState() as a mocked function as there are other return values that I need to test.
My first attempt is the following:
EXPECT_CALL(actuator, doAction()).Times(1).WillOnce(InvokeWithoutArgs(
[&](){
ON_CALL(actuator, getState()).WillByDefault(Return(State::BUSY));
}));
But that gives the following cryptic error:
/usr/src/googletest/googlemock/include/gmock/gmock-actions.h:861:64: error: void value not ignored as it ought to be
Result Perform(const ArgumentTuple&) { return function_impl_(); }