mockito

Article cover for Mockito Final Kotlin

How to mock final classes in Kotlin with Mockito?

Let’s consider the following system under test: And following test method: if you are unsure how to use Mockito with Kotlin, check https://kotlintesting.com/using-mockito-in-kotlin-projects/ After running this test it is likely that you will encounter the following error: Classes marked as „final” should not be extended Kotlin default modifier translates to „final” in Java Classes in …

How to mock final classes in Kotlin with Mockito? Read More »

Using Mockito in Kotlin projects

We will work on the following piece of code. It’s simplified version of Presenter in Model-View-Presenter pattern. Let’s see what we can and should unit test there. interface View { fun displayItems(list: List<Element>) fun displayDetails(element: Element) fun displayError()}data class Element(val id: Int, val content: String)interface DataProvider { fun getAll(): List<Element> fun getOne(id: Int): Element?}class Presenter( …

Using Mockito in Kotlin projects Read More »