title: Mockito ArgumentCaptor Capture Conditional on Matcher
body: <p>In mockito we can capture arguments for a method that might be called many times like so:</p>
  
  <pre><code>verify(mocked, atLeastOnce())
      .myMethod(myCaptor.capture());
  </code></pre>
  
  <p>Then</p>
  
  <pre><code>myCaptor.getAllValues()
  </code></pre>
  
  <p>However then I would need to sift through all the captured values to find the one I am interested in for verification.</p>
  
  <p>What I would like to do is something like this:</p>
  
  <pre><code>private class IsMySpecialArg extends ArgumentMatcher&lt;Object&gt; {
    public boolean matches(Object other) {
      // Matching condition
    }
  }
  </code></pre>
  
  <p>...</p>
  
  <pre><code>verify(mocked, atLeastOnce())
          .myMethod(myCaptor.capture(argThat(new IsMySpecialArg()));
  </code></pre>
  
  <p>So that I can simply call <code>myCaptor.getValue()</code> and be assured it is referring to the argument I was actually interested in capturing. What is the best way to accomplish this is <code>mockito</code>, is it supported, or is there something fundamentally wrong with my testing strategy?</p>