title: Mockito, Usages of doNothing() When()
body: <p>I'm new to Mockito, and I went over this example but there is one step that I do not understand when it calls <code>doNothing()</code> on the first line of the method:</p>
  
  <pre><code>@Test(expected = RuntimeException.class)
  public void testConsecutiveCalls() throws Exception(){
    doNothing().doThrow(Exception.class).when(b).voidMethod();
    a.usesVoidMethod()
    verify(b).voidMethod();
    a.usesVoidMethod()
  }
  </code></pre>
  
  <p>I do understand that when the first time <code>voidMehtod()</code> is called is returning nothing and in the second time it is giving an exception.</p>
  
  <p>But if we remove the <code>doNothing.doThrow(Exception.class).when(b).voidMethod();</code>, won't the test still be valid and will test what we want to test that the method throw an exception in the second time? </p>