Can googlemock mock method calls from within other method calls of the same class?

断了今生、忘了曾经 提交于 2019-12-06 09:42:10

Your call to MockMyClass::ReturnInputPlus1(1) calls MyClass::ReturnInputPlus1(1) on real by default, which calls MyClass::ReturnInput(2). The object that ReturnInputPlus1() is running on is not mock, it's mock.real, and when it calls ReturnInput() it calls the original version of the function. What you want to do is create a MockMyClass that has a mock override of ReturnInput() but doesn't mock out ReturnInputPlus1() at all -- you don't want to have both a mock version of your class and a real version that it sometimes delegates to.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!