The error below appeared in my code when using 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
The Stack trace that caused this:
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;
}
did I miss any thing here