Closed jim-king-2000 closed 2 months ago
You can only mock virtual functions. Basically the library works by creating fake objects with an hand-crafted vtable, so when calling a virtual function on that object it will call the mocked function that you defined in your test.
Suppose we have a function in my production code.
Now we need write a unit test for this function. And we want to spy
do2Thing()
and let it throw an exception. Pseudo-code is like this:Is it possible to do this without changing the source code of
ProductionCode
?