我有一个界面-
Interface Intf {
public void intfMethod();
}
以及实现它的2个类A和B
我正在使用JUnit和Mockito在类下面进行测试-
class CUT {
//Gets initialized as null
private Intf i;
//Gets autowired as object of A
private Intf a;
//Gets autowired as object of B
private Intf b;
public void myMethod(SomeClass param) {
if(param.getCondition())
i = a;
} else {
i = b;
}
i.intfMethod();
}
}
如何在测试中验证是否调用了正确实现的intfMethod()?