public List<Object> getDummyData(String testString) {
final List<String> result1 = utility.getData(testString);
final List<String> result2 = utility.getData(result1.get(0).split(~)[0]);
// Processing of result2 and few more method calls
return someListOfObject;
}
我需要模擬上述方法調用的方法。當我用下面的代碼去:如何嘲笑被調用兩次的方法和第二方法調用的參數是使用Mockito的第一個方法調用的輸出
MainApp mock= Mockito.mock(MainApp.class);
List<String> mockList = Mockito.mock(ArrayList.class);
doReturn(mockList).when(mock).getData("str");
我在第二次方法調用運行測試用例時得到IndexOutOfBoundsException。
任何進一步的反饋?有什麼我可以添加,讓你考慮upvote /接受? – GhostCat