title: Verifying mocked object method calls with default arguments
body: <p>Suppose I have this class:</p>
  
  <pre><code>class Defaults {
    def doSomething(regular: String, default: Option[String] = None) = {
      println(s"Doing something: $regular, $default")
    }
  }
  </code></pre>
  
  <p>I want to check that some other class invokes <code>doSomething()</code> method on <code>Defaults</code> instance without passing second argument:</p>
  
  <pre><code>defaults.doSomething("abcd")  // second argument is None implicitly
  </code></pre>
  
  <p>However, mocking <code>Defaults</code> class does not work correctly. Because default values for method arguments are compiled as hidden methods in the same class, <code>mock[Defaults]</code> returns an object in which these hidden methods return <code>null</code> instead of <code>None</code>, so this test fails:</p>
  
  <pre><code>class Test extends FreeSpec with ShouldMatchers with MockitoSugar {
    "Defaults" - {
      "should be called with default argument" in {
        val d = mock[Defaults]
  
        d.doSomething("abcd")
  
        verify(d).doSomething("abcd", None)
      }
    }
  }
  </code></pre>
  
  <p>The error:</p>
  
  <pre><code>Argument(s) are different! Wanted:
  defaults.doSomething("abcd", None);
  -&gt; at defaults.Test$$anonfun$1$$anonfun$apply$mcV$sp$1.apply$mcV$sp(Test.scala:14)
  Actual invocation has different arguments:
  defaults.doSomething("abcd", null);
  -&gt; at defaults.Test$$anonfun$1$$anonfun$apply$mcV$sp$1.apply$mcV$sp(Test.scala:12)
  </code></pre>
  
  <p>The reason of this is clear, but is there a sensible workaround? The only one I see is to use <code>spy()</code> instead of <code>mock()</code>, but my mocked class contains a lot of methods which I will have to mock explicitly in this case, and I don't want it.</p>