title: MockK spy on top-level private function in Kotlin
body: <p>I need to verify if <code>bar</code> function is called or not using MockK library.</p>
  <p>MyFile.kt</p>
  <pre><code>fun foo() {
      bar()
  }
  
  private fun bar() { ... }
  </code></pre>
  <p>How can I mock the 'bar' function?</p>
  <p>I am trying the following.</p>
  <pre><code>@Test
  fun test() {
      mockkStatic(&quot;com.mypkg.MyFileKt&quot;)
  
      every { bar() } returns Unit
  
      foo()
  
      verify(exactly = 1) { bar() }
  }
  </code></pre>
  <p>This gives compile-time error: <code>Cannot access 'bar': it is private in file</code>.</p>
  <p>It works fine if I make the bar function internal. Probably I will have to spy on it but cannot find an example to do that.</p>