How to mock a C++ function in Objective C testing

288 Views Asked by At

I am trying to write test case for an objective-C function that uses a C++ function with return type bool. Inside the Objective-C function, I am simply calling the C++ function in a conditional statement as if(CppClass::CppFunction) and proceeding accordingly. For writing the test for the said objective-C function, I need to mock the CppFunction. I am not able to do that with OCMock. What is the correct way of mocking the C++ function?

1

There are 1 best solutions below

0
Jon Reeves On

This might be overkill if you're really just trying to mock one C++ function, but you can try using Mimicc

Run it on the header which declares the C++ code you want to mock and pass the same command line arguments that you would to the clang invocation you use to compile the code.