

Given we have the mock of a class called genericClass that has the function func, with only one parameter of type GenericType that we want it to return a value called stubResponse. Verifying arguments from called functions Ps.: For cases when you want to verify if the function was called with a specific parameter it works the same way for both libraries, so the examples have been built with only one parameter using the any() generic function (which in case of Mockk will import the function from the Mockk library). We can have tests using the annotation to define our mocks, because of that we have to add the deprecated MockitoAnnotations.initMocks(this) to the function: private lateinit var mapper: GenericMapper fun beforeEach() Mocking attributesįirst lets tackle how we create our mocks by using Mockito. The aim of this document is to show how to use Mockk functionalities from the point of view of a Android developer that already uses Mockito by going through its most used features.įor each topic we will cover how it’s done in Mockito and how is the similar in Mockk.
