title: How to verify a mock interface in a test method using KotlinTest library?
body: <p>I have an interface that communicates with my presenter who checks whether the fields of a form are valid. </p>
  
  <p>My interface is:</p>
  
  <pre><code>interface MainView {
    fun showMessage(data: LoginEntity)
    fun showEmailError()
    fun showPasswordError()
  }
  </code></pre>
  
  <p>My method in the presenter is like that:</p>
  
  <pre><code>fun sendForm(loginData: LoginDataPresentation, view: MainView) {
     if (isValid()) {
       view.showMessage(mapData(loginData))
     } else if (isValidPassword()) {
       view.showPasswordError()
     } else {
       view.showEmailError()
     }
  }
  </code></pre>
  
  <p>My test class with KotlinTest:</p>
  
  <pre><code>class LoginPresentationKtTest : StringSpec() {
  
    init {
      "given a bunch of Login Data should be matched successfully" {
         forAll(EmailGenerator(), PasswordGenerator(), { email: String, password: String -&gt;
  
           val loginData: LoginDataPresentation(email, password)
  
           val mockMainView = mockMainView()
  
           sendForm(loginData, mockMainView())
  
         })
      }
    }
  
    private fun mockMainView(): MainView {
      //How to mock?????
    }
  }
  </code></pre>
  
  <p>Using the KotlinTest library, is there any way to verify that the call to the showMessage method of the MainView class is done provided that the email and password generated is always correct? Is it possible to use a mock library like mockito?</p>
  
  <hr>
  
  <p>With the response of the user @mkobit, the following modification can be made using Mockito-Kotlin, with which the test would be as follows:</p>
  
  <pre><code>class LoginPresentationKtTest : StringSpec() {
   init {
     "given a bunch of Login Data should be matched successfully" {
       forAll(EmailGenerator(), PasswordGenerator(), { email: String, password: String -&gt;
  
         val loginData = LoginDataPresentation(email, password)
  
         val mockMainView = Mockito.mock(MainView::class.java)
  
         sendForm(loginData, mockMainView)
  
         verify(mockMainView).showMessage()
         true
       })
     }
   }
  }
  </code></pre>
  
  <p>At each execution of the loop, it will be checked if the verify () function has been called. If the execution flow is the expected one, it will proceed to the next execution of the loop. If the verify () function fails, an error will occur in the console indicating that the test has failed.</p>
  
  <p>Is there any better solution?</p>