I'm fairly new to C++ and Unit testing and I'm learning to use Google Mock and Google Test right now to test some code that I'm working with. Instead of writing all of the Google Mock methods manually, is there a way to point Google Mock to your class and have it automatically generate all of the Google Mock methods for all of your functions?
Someone told me they think it should be possible, but as I'm new to this (Just started learning C++ a few weeks ago) I have no idea if this is possible.
" Instead of writing all of the Gmock methods manually, is there a way to point Gmock to your class and have it automatically generate all of the Gmock methods for all of your functions?"
Well, what I'm doing most of the time is copying a line from the interface
struct IFace {
int doThefancyOperatiion(std::string s, int i) = 0;
};
and change it to
struct MockIface {
MOCK_METHOD2(doThefancyOperatiion, int (std::string s, int i));
};
Looks like it can be done with sed
or any other fairly decent tool for text replacement. Not I'm aware of a particular one, that does this for you.