Is there any way to stub a class member function which has been defined in CPP files completely. The code is very old and we cannot modify the structure of code for the sake of unit testing.
Is the member function only used within the source file it was defined? Stubs are generated from invocations of functions when their definitions are not included in the testing scope. If the function is used in a file other than which it was defined, generating stubs from only that file with the definition excluded should generate a stub.
Otherwise, you may want to look into creating a factory function https://docs.parasoft.com/display/CPPDESKE1041/Using+Factory+Functions similar to the original member definition which performs the same function and is able to be used in test cases as a substitute.
I would be interested to know why the legacy code needs to be stubbed but is also not able to be modified. It is possible that proper unit test setup may be enough to cover your use cases. If you are able to share the source code in question, we can investigate further through a support case at: