Closed jamespharvey20 closed 7 years ago
FakeIt manipulates the virtual table. It can't handle c functions. Your only option is to create a cpp abstract class and use it for mocking.
On Oct 1, 2016 04:34, "jamespharvey20" notifications@github.com wrote:
Need to add a mock library to my unit tests.
All of my development is c++11, so I like the looks of FakeIt, but I do use the MySQL c connector. I have database classes that use it internally, and would like to mock out the MySQL c connector library.
I'd like to avoid writing an abstract base class defining an interface to the MySQL library, with a class inheriting from it that uses the MySQL c connector, and another being a mock class. I'd prefer to be able to mock the actual MySQL c functions, so I don't leave the derived class that uses the MySQL c connector untested, admittedly it would basically be a straight passthrough.
Can FakeIt help with this, or do I need to look for another mock library or use pre-processor or linker methods for C functions?
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/eranpeer/FakeIt/issues/73, or mute the thread https://github.com/notifications/unsubscribe-auth/ACc8gkBXcsQuFbn2bJkY7kOIDOY4ehwuks5qvbimgaJpZM4KLotO .
Thanks!
Need to add a mock library to my unit tests.
All of my development is c++11, so I like the looks of FakeIt, but I do use the MySQL c connector. I have database classes that use it internally, and would like to mock out the MySQL c connector library.
I'd like to avoid writing an abstract base class defining an interface to the MySQL library, with a class inheriting from it that uses the MySQL c connector, and another being a mock class. I'd prefer to be able to mock the actual MySQL c functions, so I don't leave the derived class that uses the MySQL c connector untested, admittedly it would basically be a straight passthrough.
Can FakeIt help with this, or do I need to look for another mock library or use pre-processor or linker methods for C functions?
I looked through the examples and issues, and don't see anything showing mocking c functions, but wanted to ask before I assumed it can't do it.