title: Mock a void method with a delay
body: <p>How do I go about mocking a void method and also replace what that method executes? I'd like to mock the method so it does a thread.sleep to simulate work.</p>
  
  <p>I've tried </p>
  
  <pre><code>Mockito.doAnswer(new Answer&lt;Void&gt;(){
      Void answer(InvocationOnMock invocation) {
          Thread.sleep(1000);
          return null;
      }
  }.when(Class).myVoidMethod((OtherClass) Mockito.any());
  </code></pre>
  
  <p>but it complains that I'm not mocking it right and gives me examples of using doException or thenReturn.</p>