【发布时间】:2017-11-02 23:26:10
【问题描述】:
我从来不需要存根一个接受函数接口/方法引用作为参数的调用,所以我只是发现除了引用比较之外,显然无法与“等于”这些比较。
那么在测试期间如何处理这种情况呢?我们是否必须使用 any() 我们想要或不想要它?
Comparator<String> comparator = Comparator.naturalOrder();
when(myColaborator.isCalledWith(comparator)).thenReturn("foo"); //This is not gonna work as long as the real call does not use theat very same reference
【问题讨论】:
标签: java junit mockito stubbing functional-interface