You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a common scenario:
class B has an A object, so class B member function can call class A member function with A object.
so how can i mock class A member function when i perform unit testing on class B member function?
example code like below:
I expect iTest_OutputValueByPointer call vOutputValueByPointer mock function and l_acStr equal “HELLOWORLD”, but iTest_OutputValueByPointer actually call class memberFuncHeader function then output 'origin' to l_acStr.
can do this with trompeloeil?
and i push the demo code at demo
The text was updated successfully, but these errors were encountered:
You need to make the A member accessible in the test so that you can place an expectation on it. One traditional technique for this is dependency injection, i.e. you create your B with the mocked A for the test.
Yeah, I know what you mean, but that's a real huge workload, because there's a lot of historical code (T_T). And they are running at product....
So, i want to found some solution that can integrated unit testing without requiring too many source code changes。
There are many codes like demo in historical code。Although not the best, but it work。 So i can not change every class to dependency injection。
Thanks。
This is a common scenario:
class B has an A object, so class B member function can call class A member function with A object.
so how can i mock class A member function when i perform unit testing on class B member function?
example code like below:
the unit test code like below:
I expect iTest_OutputValueByPointer call vOutputValueByPointer mock function and l_acStr equal “HELLOWORLD”, but iTest_OutputValueByPointer actually call class memberFuncHeader function then output 'origin' to l_acStr.
can do this with trompeloeil?
and i push the demo code at demo
The text was updated successfully, but these errors were encountered: