I know there is a tool called gmock_gen.py in google mock that can be used to automatically generate mocks for c++ classes. Is there any similar tool that can generate mock for c functions, given a c source file, in which I want to mock those functions?
The background for my question:
I have lots of legacy c code (not c++) that need to be unit tested by google test and google mock. To test a function, I have to mock hundreds of functions that are called by some functions in the same c source file, even though they are not called by the function under unit test, otherwise, there will be "undefined reference" problems when linking.
Maybe you could take a look at this github repo : https://github.com/hjagodzinski/C-Mock
From the doc :
C Mock is Google Mock extension allowing for mocking functions.
This is not either a patch to nor fork of Google Mock. This is just a set of headers providing a way of using tools for mock methods with mock functions in tests.
C Mock is not intended to promote bad design. Its goal is to help people test their code.