检测到未完成的存根



使用mockit时,我的代码中出现了以下错误:

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;
    }

我有什么遗漏吗

删除PowerMockito.doNothing().when(ASKService.class);在它对我起作用之前的声明。

相关内容

  • 没有找到相关文章

最新更新