title: Kotlin Mockk Error: Missing calls inside verify { ... } block
body: <p>I already read some issues with this or a similar error message (it is also ocurring for every {}), but none of them took me to a success result.</p>
  
  <p>Any hints or suggestions on how to get this to work?</p>
  
  <p>Here is my setup and the Unit Test itself:</p>
  
  <pre><code>compileSdkVersion 29
  defaultConfig {
     minSdkVersion 19
     targetSdkVersion 29
     testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
  }
  
  MockK version: 1.9.3.kotlin12
  OS: Android
  Kotlin version: 1.3.61
  JDK version: jdk1.8.0_212
  JUnit version: 4.12
  Type of test: unit test
  </code></pre>
  
  <p>The stacktrace of the error:</p>
  
  <pre><code>io.mockk.MockKException: Missing calls inside verify { ... } block.
  
      at io.mockk.impl.recording.states.VerifyingState.checkMissingCalls(VerifyingState.kt:52)
      at io.mockk.impl.recording.states.VerifyingState.recordingDone(VerifyingState.kt:21)
      at io.mockk.impl.recording.CommonCallRecorder.done(CommonCallRecorder.kt:47)
      at io.mockk.impl.eval.RecordedBlockEvaluator.record(RecordedBlockEvaluator.kt:60)
      at io.mockk.impl.eval.VerifyBlockEvaluator.verify(VerifyBlockEvaluator.kt:30)
      at io.mockk.MockKDsl.internalVerify(API.kt:118)
      at io.mockk.MockKKt.verify(MockK.kt:139)
      at io.mockk.MockKKt.verify$default(MockK.kt:136)
  </code></pre>
  
  <p>My Unit Test:</p>
  
  <pre><code>@Test
  fun logout_clearsDatabase() {
      coroutineTestRule.testDispatcher.runBlockingTest {
  
          // ARRANGE
          database.dataDao().insert(listOf(DataDummies()))
  
          // ACT
          sut.logout()
  
          // ASSERT
          verify { database.clearAllTables() }
      }
  }
  </code></pre>
  
  <p>I have no clue what I did wrong here. <code>database.clearAllTables()</code> is a method provided by Room. The <code>testDispatcher</code> is a <code>TestCoroutineDispatcher()</code> provided by the androidx testing library.</p>
  
  <p><strong>UPDATE / ANSWER</strong></p>
  
  <p>Thanks to the input of @Juan Cruy Soler I changed the way of injecting the database. I did not return the real room database, instead I return a spy of it. That way the spy is injected into the SUT as well as into my test class. After that change the test runs as excpected. I this a feasible solution to my problem? Does it make sense to let the (Testing-)DependencyInjection create a spy?</p>