Quick testing tips #4


Use Mockito-Kotlin on top of Mockito to declare stubbing in dsl




import com.nhaarman.mockitokotlin2.doReturn
import com.nhaarman.mockitokotlin2.mock

val dataProvider: DataProvider = mock {
  on { getAll() } doReturn listOf(
    Element(1, "first"),
    Element(2, "second")
  )
}



Regular Mockito is great tool, but Mockito-Kotlin gives you more power to write expressive test code in Kotlin idiomatic way.



Read next:


Loading ...
Failed to load data.