考虑以下Java类
public class SomeClass {
public void validateSomething(List<String> exceptions) {
//Nothing here
}
}
public class AnotherClass {
public SomeClass someClass;
public void validate() {
List<String> exceptions = new List<>();
someClass.validateSomething(exceptions);
if(exceptions.length > 0)
//do something
}
}
如何使用mockito模拟SomeClass并使其在异常列表中添加一个项目,以便代码路径中的exceptions.length&gt; 0将为AnotherClass执行?