How to mock a void static method to throw exception with Powermock?

前端 未结 3 1758
我在风中等你
我在风中等你 2020-12-15 03:23

I am trying to use Powermock and Mockito to mock a void static method to throw exception as below. But I met a problem. Unless I make the two invocations of Adder.add() with

3条回答
  •  渐次进展
    2020-12-15 04:00

    Or

    PowerMockito.mockStatic(Adder.class);
    PowerMockito.doThrow(new IOException()).when(Adder.class, "add", Mathers.eq(12));
    

提交回复
热议问题