title: PowerMockito: doThrow unfinished stubbing
body: <p>I am trying to simulate a failure condition in my JUnit test by throwing an exception. However, it seems I am failing to stub some method correctly.</p>
  
  <p>My code is as follows:</p>
  
  <pre><code>private MyClass mockObject;
  
  @Before
  public void setUp() throws Exception {
      MockitoAnnotations.initMocks(this);
  
      mockObject = PowerMockito.mock(MyClass.class);
      whenNew(MyClass.class).withAnyArguments().thenReturn(mockObject);
  }
  
  @Test
  public void testFailure() throws Exception {
      PowerMockito.doThrow(new Exception("This is a test exception.")).when(mockObject).register(anyString());
      ...
  }
  </code></pre>
  
  <p>, where the return type of <code>register</code> is <code>void</code>.</p>
  
  <p>However, when I execute this test, I get an unfinished stubbing exception on the <code>doThrow</code> call.</p>
  
  <pre><code>org.mockito.exceptions.misusing.UnfinishedStubbingException: 
  Unfinished stubbing detected here:
  -&gt; 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!
  </code></pre>
  
  <p>Can anyone help identify what I am missing here?</p>
  
  <p>In case it helps, the dependency versions are 1.5.6 for both powermock-api-mockito and powermock-module-junit4 in my pom.</p>