使用 mockito 时,我的代码中出现以下错误:
org.mockito.exceptions.misusing.UnfinishedStubbingException:
Unfinished stubbing detected here:
-> at org.powermock.api.mockito.internal.PowerMockitoCore.doAnswer(PowerMockitoCore.java:36)
E.g. thenReturn() may be missing.
Examples of correct stubbing:
when(mock.isOk()).thenReturn(true);
when(mock.isOk()).thenThrow(exception);
doThrow(exception).when(mock).someVoidMethod();
Hints:
1. missing thenReturn()
2. you are trying to stub a final method, you naughty developer!
3: you are stubbing the behaviour of another mock inside before 'thenReturn' instruction if completed
导致此问题的堆栈跟踪:
PageCodeBase mockPageCodeBase = Mockito.mock(PageCodeBase.class);
Map<String, String> nn = getStringV();
when(mockPageCodeBase.getRequestParam()).thenReturn(nn);
private Map<String, String> getStringV(){
Map<String, String> mapV = new HashMap<String, String>();
mapV.put("selectedApplicantId", "selectedApplicantId");
return mapV;
}
我在这里错过了什么吗