I am pioneering unit testing efforts at my company, and need need to choose a mocking framework to use. I have never used a mocking framework before. We have already chosen Google Test, so using Google Mock would be nice. However, my initial impressions after looking at Google Mock's tutorial are:
- The need for re-declaring each method in the mocking class with a MOCK_METHODn macro seems unnecessary and seems to go against the DRY principle.
- Their matchers (eg, the '_' in EXPECT_CALL(turtle, Forward(_));) and the order of matching seem almost too powerful. Like, it would be easy to say something you don't mean, and miss bugs that way.
I have high confidence in google's developers, and low confidence in my own ability to judge mocking frameworks, never having used them before. So my question is: Are these valid concerns?
Or is there no better way to define a mock object, and are the matchers intuitive to use in practice? I would appreciate answers from anyone who has used Google Mock before, and comparisons to other C++ frameworks would be helpful.
gmock_gen.py
can usually write the mock for you (given the header file and base class as input). Since C++ is complex, it may botch up, but that'll still cover most of the usecases so it does speeds things up. – Othaothegooglemock
's move-semantics support, which is mostly absent. You cannot use move-only types as arguments and you cannot use rvalue references as parameters. Unfortunately, as I know, google team doesn't have recent plans to update the project. – Thury