title: doAnswer in mockito - when is it lazy evaluation and when is it eager?
body: <p>I'm using mockito spy with this code:</p>
  
  <pre><code>Mockito.doAnswer(new Answer() {
      Object answer(InvocationOnMock invocation) {
           ImagesSorter mock = (ImagesSorter) invocation.getMock();
           Object[] args = invocation.getArguments();
  
           return mock.sortImages((List&lt;Image&gt;) args[0], (UserInfo) args[1],
                   fakeNowDate);
      }
  }).when(imagesSorterSpy).sortImages(imagesAsInsertionOrder, user);
  </code></pre>
  
  <p>And I see the answer() is called eagerly when the struct is:</p>
  
  <p><code>when(spy.method())./*...*/.</code></p>
  
  <p>but it's lazy evaluation when the struct is:</p>
  
  <p><code>/*...*/.when(spy).method()</code></p>
  
  <p>Shouldn't it be vise versa? Meaning <code>/*...*/.when(spy).method()</code> is eager versus <code>when(spy.method())./*...*/.</code> is lazy? Like <code>do..while loop</code> ? </p>
  
  <p>I couldn't find documentation for that</p>