I have a Android Clean Architecture project write in Kotlin with 3 modules:
Mockito's MockMaker can only be used for unit tests (run on JVM). For those who are having problems with mocking Kotlin classes in instrumentation tests (androidTest), try using the DexOpener library. It makes Kotlin classes, properties and methods open
, which allows their mocking.
You can use the inline mocking method by default, by changing your Gradle dependency from the normal Mockito dependency:
compile "org.mockito:mockito-core:$mockito_version"
... to the following:
compile "org.mockito:mockito-inline:$mockito_version"
This way you won't have to rely on activating inline mocking with the "file in the resources folder" method, which I have found to be flaky sometimes.