使用PowerMockito和Mockito时检测到未完成的存根

时间:2019-03-06 09:31:29

标签: vert.x

AsyncResult<Authentication> asyncResultSet = Mockito.mock(AsyncResult.class);

Mockito.doAnswer(new Answer<AsyncResult<Authentication>>() {

            @Override
            public AsyncResult<Authentication> answer(InvocationOnMock invocation) throws Throwable {
                ((Handler<AsyncResult<Authentication>>) invocation.getArgument(2)).handle(asyncResultSet);
                return null;
            }
        }).when(apiUtil).doAuthentication(Mockito.any(), Mockito.any(), Mockito.any());

如何模拟静态void方法?如果我在doAnswer()中进行了模拟,给出了空指针异常。

0 个答案:

没有答案