【发布时间】:2016-07-27 02:50:29
【问题描述】:
我正在尝试添加自定义的ArgumentMatcher(subclass of Matcher) 用于模拟测试,以下是代码:
when(mockedObject.mockedMethod(
argThat((int id)-> id > 5 || id < 1 ? false : true)));
但我收到错误:
在接口 org.hamcrest.Matcher 中找到多个非覆盖抽象方法
我知道argThat被定义为:
public static <T> T argThat(Matcher<T> matcher)
我可以告诉编译器我想在 lambda 表达式中使用 ArgumentMatcher,而不是 Matcher 吗?
谢谢!
【问题讨论】: