Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/393.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 使用'时出现Mockito错误;何时';功能_Java_Mocking_Mockito - Fatal编程技术网

Java 使用'时出现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所属的对象在哪里

在尝试使用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所属的对象在哪里?它应该是
when(someMock.myFun(arg1,arg2))
,当然可以吗?您可以发布失败的myFun的示例代码吗?