模拟未来对象

时间:2017-03-23 14:37:29

标签: java mockito future

我遇到了抛出InterruptedException的问题。 我的部分资料来源:

    Future<Object> future = mock(Future.class);
    when(future.get(any(), any())).thenThrow(new InterruptedException());

但是我在第二行得到了java.lang.NullPointerException,我的代码出了什么问题?我想在调用get方法

时抛出InterruptedException

0 个答案:

没有答案
相关问题