正如标题所示,我正在向现有的不太适合测试的代码添加一些测试,我需要测试复杂的方法是否真的调用了另一个方法,例如。
class SomeView(...):
def verify_permission(self, ...):
# some logic to verify permission
...
def get(self, ...):
# some codes here I am not interested in this test case
...
if some condition:
self.verify_permission(...)
# some other codes here I am not interested in this test case
...
我需要写一些测试用例来验证
self.verify_permission
在满足条件时调用。
我需要一直嘲笑到
self.verify_permission
被执行?或者我需要重构
def get()
函数来抽象出代码以变得更便于测试?