title: Argument passed to when() is not a mock! Example of correct stubbing: doThrow(new RuntimeException()).when(mock).someMethod();
body: <p>When using Mockito in JUnit4, I encounter the error in the title.</p>
  
  <p>My code is shown below</p>
  
  <pre><code>package cn.patest.judgerAutoscalerKotlin
  
  import org.junit.Test
  import org.mockito.*
  
  import java.lang.RuntimeException
  
  class CalculateScaleToTest {
      @Mock
      private lateinit var test: cn.patest.judgerAutoscalerKotlin.Test
  
      private fun mockTest() {
          test = cn.patest.judgerAutoscalerKotlin.Test()
          Mockito.doAnswer { 1 }.`when`(test).test()
      }
  
  
      @Test
      fun z() {
          mockTest()
      }
  }
  </code></pre>
  
  <pre><code>package cn.patest.judgerAutoscalerKotlin
  
  class Test() {
      fun test(): Int {
          return 1
      }
  }
  </code></pre>
  
  <p>Error details are shown below:</p>
  
  <blockquote>
    <p>org.mockito.exceptions.misusing.NotAMockException: 
    Argument passed to when() is not a mock!
    Example of correct stubbing:
        doThrow(new RuntimeException()).when(mock).someMethod();
      at cn.patest.judgerAutoscalerKotlin.CalculateScaleToTest.mockTest(CalculateScaleToTest.kt:53)
        at cn.patest.judgerAutoscalerKotlin.CalculateScaleToTest.z(CalculateScaleToTest.kt:61)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
        at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
        at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
        at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
        at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
        at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
        at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
        at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
        at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
        at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
        at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
        at org.junit.runner.JUnitCore.run(JUnitCore.java:137)</p>
  </blockquote>
  
  <p>I searched with google and found some similar issues but they have different situations from mine.</p>