agiledragon / gomonkey

gomonkey is a library to make monkey patching in unit tests easy
MIT License
1.93k stars 179 forks source link

Quesion of calling original function #53

Open cutecutecat opened 2 years ago

cutecutecat commented 2 years ago

After I have mocked a function A by function B, is there any way to call original A function inside B? Which might be helpful for user to check or log arguments and return values. Thanks!

如果我用B函数替换了对A函数的调用,那么有没有办法在B函数体内部,完成正常的A函数调用流程,这样会对函数参数以及返回值的检查或者统计会有很大帮助。 非常感谢!

mxpaul commented 2 years ago

I miss same functionality: trying to test Mutex.Lock() and Mutex.Unlock() method calls but need to execute original code from patched function to not break things like testify/assert, etc (those who uses mutexes internally)

Found no solution for the moment