Using google mock for C code

后端 未结 3 1939
无人及你
无人及你 2020-12-05 10:41

I\'m maintaining a legacy project written in C and it\'s unfeasible to get it running with a C++ compiler. Since the code is cross compiled it is however possible to run uni

3条回答
  •  渐次进展
    2020-12-05 11:32

    Your question specifically mentions Google Mock, but then does not state any other reason for using that framework. The other answer suggests using a workaround which seems unnecessarily intrusive.

    Hence I hope I am allowed to make an alternative suggestion which works well without having to use weak aliases etc.

    I have used CppUTest (https://cpputest.github.io/) for unit test with mock, successfully on a couple of large mainly-C projects (some C++). The mocking works without having to resort to any subterfuge of the above sort.

    Unfortunately the project documentation is a little weak, some better (if a little agile-doctrinaire) information and examples in the book (also seen circulating as a PDF) "Test Driven Development for Embedded C" - James W Greening (ISBN-13: 978-1-934356-62-3)

提交回复
热议问题