title: Count indirect method calls Mockito
body: <p>I'm having problems with counting method calls with Mockito. Problem is that the method whos calls I want to count is called in test class indirectly by other method. Here is the code:</p>
  
  <pre><code>public class ClassForTest {
      private Integer value;
  
      public void doSmth() {
          prepareValue("First call");
          prepareValue("Second call");
          prepareValue("Third call");
          System.out.println(value);
      }
  
      protected void prepareValue(String msg) {
          System.out.println("This is message: " + msg);
          value++;
      }
  }
  </code></pre>
  
  <p>And the test class:</p>
  
  <pre><code>public class ClassForTestTest extends TestCase {
      @Test
      public void testDoSmth() {
          ClassForTest testMock = mock(ClassForTest.class);
          doNothing().when(testMock).prepareValue(anyString());
          testMock.doSmth();
          verify(testMock, times(3)).prepareValue(anyString());
      }
  }
  </code></pre>
  
  <p>Having such exception:</p>
  
  <pre><code>Wanted but not invoked:
  classForTest.prepareValue(&lt;any&gt;);
  -&gt; at org.testing.ClassForTestTest.testDoSmth(ClassForTestTest.java:24)
  
  However, there were other interactions with this mock:
  -&gt; at org.testing.ClassForTestTest.testDoSmth(ClassForTestTest.java:21)
  </code></pre>
  
  <p>Any ideas please. Thanks in advance!</p>