title: Is there a way to verify that a top-level function passed as a dependency to a class has been called during testing?
body: <p>I have a class that receives a function allowing it to display things on the UI during a failure case. What's the best way that I can verify that the function is called in my test?</p>
  
  <pre><code>MyClass(private val uiPrinter: (String) -&gt; Unit) {
      fun foo() {
          // do some stuff
          uiPrinter("printing from foo!")
          // do some more stuff 
      }
  }
  
  MyClassTest() {
      val testUiPrinter: (String) -&gt; Unit = { System.out.println(it) }
  
      @Test
      fun uiPrinterIsInvoked() {
          val myClass = MyClass(testUiPrinter)
          myClass.foo()
          // can I verify that testUiPrinter has been invoked?
      }
  }
  </code></pre>