How to mock method with optional parameter in Google Mock?
问题 How to mock a method with optional parameter in Google Mock ? For example: class A { public: void set_enable( bool enabled = true ); }; class MockA : public A { MOCK_METHOD1( set_enable, void( bool ) ); // this is not working }; 回答1: This is an alternative of Marko's answer: If you don't want to change your original code, just implement the helper in the mock class: class A { public: virtual void set_enable( bool enabled = true ); }; class MockA : public A { MOCK_METHOD1( set_enable_impl,