我在用
Mockito.spy(...)
在非模拟对象上验证其方法之一从未被调用但是,有一点模棱两可,因为我只是用
any(), any()
,并且有两个重载具有两个参数:
我对Java还不太熟悉,无法找到正确的方式来表达Mockito对我的要求我想我不太懂Java中的反射概念,
例如
差异
Class
,
Function
,兰姆达斯等。
这里有一个例子
实际的
(非Mockito)使用该方法:
return jdbiExecutor.execute(Foo.class,
foo -> {
// Some code.
return Bar.newBuilder().build();
});
所以,我要验证的是第一个需要
Function<D, T>
第二个参数我试过但没用的东西:
// Is specifying just one of the parameters enough?
verifyZeroInteractions(executor.execute(any(Foo, any()));
// Maybe I need to supply the `.class()`?
verifyZeroInteractions(executor.execute(any(Foo.class, any()));
// Or literally, `Class<Foo>`?
verifyZeroInteractions(executor.execute(any(Class<Foo>), any()));
// Or what, do I _have_ to specify both parameters to some degree?
我怎样才能让它工作?