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
Or
PowerMockito.mockStatic(Adder.class); PowerMockito.doThrow(new IOException()).when(Adder.class, "add", Mathers.eq(12));