Mockito Exception - when() requires an argument which has to be a method call on a mock

后端 未结 9 2324
终归单人心
终归单人心 2020-12-15 15:12

I have a very simple test case that is using Mockito and Spring Test framework. When I do

when(pcUserService.read(\"1\")).thenReturn(pcUser);
9条回答
  •  粉色の甜心
    2020-12-15 15:51

    In case others hit this issue....

    It could also be the case that the method you are trying to mock out,pcUserService.read, is declared as a final method. From what I've noticed this appears to cause issues with Mockito.

提交回复
热议问题