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