title: Override Mockito toString test output
body: <p>I have written a custom <a href="http://hamcrest.org/JavaHamcrest/javadoc/1.3/org/hamcrest/Matcher.html" rel="noreferrer">Hamcrest <code>Matcher&lt;Double&gt;</code></a> to use with <a href="http://docs.mockito.googlecode.com/hg/org/mockito/Matchers.html#doubleThat%28org.hamcrest.Matcher%29" rel="noreferrer"><code>Mockito.doubleThat</code></a>.</p>
  
  <p>I want to "override the <code>toString()</code>" method, so to speak, so that if there's a failure, the error is more verbose. Here's the JUnit failure trace:</p>
  
  <pre><code>Argument(s) are different! Wanted:
  dependedOnComponent.method(
      &lt;Double matcher&gt;
  );
  -&gt; at my.domain.TestClass.testMethod(TestClass.java:123)
  Actual invocation has different arguments:
  dependedOnComponent.method(
      123.45,
  );
  -&gt; at my.domain.SystemUnderTest.callingMethod(SystemUnderTest.java:456)
  </code></pre>
  
  <p>As you can see, it prints <code>&lt;Double matcher&gt;</code>. Is it possible to override that message? Instead, I would like to see, as an example:</p>
  
  <pre><code>Argument(s) are different! Wanted:
  dependedOnComponent.method(
      120 &lt; matcher &lt; 121
  );
  </code></pre>
  
  <p>But a different instantiantion of my matcher class might be:</p>
  
  <pre><code>Argument(s) are different! Wanted:
  dependedOnComponent.method(
      1 &lt; matcher &lt; 200
  );
  </code></pre>
  
  <p><strong>I don't need to know how to write the code to generate the numbers or the syntax, I just need to know WHERE to put it.</strong></p>