title: Mockito - Return mocked object everytime a method is called
body: <p>I am trying to write a unit test for a piece of code I am writing using Mockito.</p>
  
  <p>I need to return a mocked object whenever any class of a given type calls a certain method.</p>
  
  <p>I was thinking something like the following but I can't seem to get it working.</p>
  
  <pre><code>    Mockito.when(Mockito.any((MyObject.class).myMethod(Mockito.anyString()))).thenReturn(mockedObject); 
  </code></pre>
  
  <p>Basically any time any instance of MyObject calls it's myMethod() method I want to return a mockedObject.</p>
  
  <p>Any know it this is possible?</p>