mocking

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 »

Mocking and stubbing suspend functions with MockK

Prerequisites Lets suppose that in our system we have dependency on use case with suspend method: interface ProvideCurrentUser { suspend fun execute(): UserDetails}data class UserDetails(val id: String, val name: String) This use case is responsible for resolving user currently logged in to app. We have also dependency on repository, also with suspend function getUserById: interface …

Mocking and stubbing suspend functions with MockK Read More »