0
我想模擬以下方法。但是我沒有找到任何使用Java.util.Function
的第二個參數Mockito.Matchers
。Mockito/PowerMockito - 模擬接收Lambda表達式作爲參數的方法
public List<String> convertStringtoInt(List<Integer> intList,Function<Integer, String> intToStringExpression) {
return intList.stream()
.map(intToStringExpression)
.collect(Collectors.toList());
}
我期待這樣的事情:
Mockito.when(convertStringtoInt(Matchers.anyList(),Matchers.anyFunction()).thenReturn(myMockedList)
@Glictch。這工作完美。輝煌! 'Mockito.when(convertStringtoInt(Matchers.anyList(),Mockito。 anyObject()))。然後返回(myMockedList);' –
naga1990