如果您只想模拟car.printDelegate()的返回值,那么如何模拟该调用的任何Print实例呢?
when(car.printDelegate(org.mockito.Matchers.any(Print.class))).thenReturn(9);
顺便说一下,我对您的以下代码感到困惑:
List<String> list=new linkedList<String>(); // allocate a empty list worth list=car.getList(); // nothing but wasting memory....return num; // no definition, do you mean printedLines?



