Java 使用'时出现Mockito错误;何时';功能
在尝试使用mockito时,我遇到了以下错误Java 使用'时出现Mockito错误;何时';功能,java,mocking,mockito,Java,Mocking,Mockito,在尝试使用mockito时,我遇到了以下错误 "the method when(t) in the type mockito is not applicable for the arguments (void)" 我的代码看起来像 when(myFun(arg1, arg2)).thenReturn(fun()); myfun不是void。我在SO中发现了一些帖子,其中由于myFun返回void,出现了相同的错误,但在我的例子中并非如此。发生这种情况还有其他原因吗?myFun所属的对象在哪里
"the method when(t) in the type mockito is not applicable for the arguments (void)"
我的代码看起来像
when(myFun(arg1, arg2)).thenReturn(fun());
myfun不是
void
。我在SO中发现了一些帖子,其中由于myFun
返回void
,出现了相同的错误,但在我的例子中并非如此。发生这种情况还有其他原因吗?myFun所属的对象在哪里?它应该是when(someMock.myFun(arg1,arg2))
,当然可以吗?您可以发布失败的myFun的示例代码吗?