[ACCEPTED]-Automatic generation of mock classes for gmock-googlemock

Accepted answer
Score: 20

There is a tool bundled with the google 19 mock project that will help you do this. However 18 I think the tool requires python to be installed, and 17 I don't know how well it works in a windows 16 environment. I've also found that the generated 15 files sometimes need a little tweak to work 14 perfectly.

Here's the info from the docs:

Tip: If 13 even this is too much work for you, you'll 12 find the gmock_gen.py tool in Google Mock's 11 scripts/generator/ directory (courtesy 10 of the cppclean project) useful. This command-line 9 tool requires that you have Python 2.4 8 installed. You give it a C++ file and 7 the name of an abstract class defined in 6 it, and it will print the definition of 5 the mock class for you. Due to the complexity 4 of the C++ language, this script may not 3 always work, but it can be quite handy when 2 it does. For more details, read the user 1 documentation.

Here is new localization of this script.

Score: 3

Disclaimer: I used to work at Typemock

Have you considered using another tool?
Typemock 3 has a tool called Isolator++ that do not need you 2 to write "mocking classes".

TEST_F(IsolatorTests, SomeTest) 
      AClass* fakeclass = FAKE(AClass);

      ASSERT_EQ(10, fakeclass.AFunction()); 

You 1 can learn more about it at this about page

More Related questions