title: Using Mockito doAnswer in Kotlin
body: <p>what would be the Kotlin equivalent to this Java code?</p>
  
  <pre><code>doAnswer(new Answer() {
      @Override
      public Object answer(InvocationOnMock invocation) throws Throwable {
          Design design = new Design();
          GetDesign.Listener callback = (GetDesign.Listener) invocation.getArguments()[0];
          callback.onSuccess(design);
          return null;
      }
  }).when(someRepository).getDesign(any(GetDesign.Listener.class));
  </code></pre>
  
  <p>[UPDATE] After trying several options, I finally made it work using <a href="https://github.com/nhaarman/mockito-kotlin" rel="noreferrer">mockito-kotlin</a>. I think that's the most comfortable way of implementing <code>doAnswer</code>. Syntax remains almost the same:</p>
  
  <pre><code>doAnswer {
      callback = it.arguments[0] as GetDesign.Listener
      callback.onSuccess(Design())
      null
  }.whenever(someRepository).execute(any(GetDesign.Listener::class.java))
  </code></pre>
  
  <p>Complete code and build.gradle configuration can be found <a href="https://github.com/voghDev/HelloKotlin/blob/master/app/src/test/java/es/voghdev/hellokotlin/SomeAsyncPresenterTest.kt" rel="noreferrer">here</a></p>