Mockito's verify method interferes with doAnswer's checks
<p>When using mocks for unit testing, I often encounter the need to check whether a certain method of the mock is invoked <em>with proper arguments</em>. This means that I have to somehow find a way to peek into what gets passed to the method in question. In Spock this can be done using something like:</p>

<pre><code>1 * serviceMock.operate(*_) &gt;&gt; { args -&gt;
    def argument = args[0]
    assert expectedValue = argument.actualValue
}
</code></pre>

<p>With Mockito (and JUnit), the only way I think this can be done is by using <code>doAnswer</code> and <code>verify</code>, something like:</p>

<pre><code>doAnswer(new Answer() {
  //check arguments here
}).when(service).operate(any(Data.class));
</code></pre>

<p>Then I have to verify that the operation actually gets called with:</p>

<pre><code>verify(service).operate(any(Data.class));
</code></pre>

<p>The code above, however, interferes with <code>doAnswer</code> as if it's an actual call to the method in question. How do I work around this so that I can both verify that the method is called, and verify that the arguments it gets are correct?</p>