Quick testing tips #10


Use MockK verify to assert interactions on mocks




import io.mockk.mockk
import io.mockk.verify
import org.junit.jupiter.api.Test

class Test {
  @Test
  fun `it should pass`() {
    val view: View = mockk(relaxUnitFun = true)
    verify { view.showLoading() }
  }
}



Verify interactions on mocks created with MockK - when you need to check if some action on given object was executed. Syntax is very similar to Mockito.



Read next:


Loading ...
Failed to load data.