Could someone help me using kotlin with androidInstrumentationTests? I'm getting a "cannot mock final class" exception. I got it working with unit tests with the MockMaker solution, but I'm having trouble with the android tests.
d
dave08
02/05/2018, 3:33 AM
It some mock frameworks, you can't mock final classes, in Kotlin they're all final unless you 'open' them, or I think there's a gradle option for opening all classes for tests....
@tinashe I read the article, and I have it working with this solution for junit tests, but it won't work with androdInstrumentalTests, is that somehow different? Do you have any experience wiht that?
t
tinashe
02/05/2018, 9:30 AM
No unfortunately, I thought that solution would work as well
t
Tamás
02/05/2018, 9:32 AM
@dave08 yes I know, I was looking for a better solution. I read about dexopener which I haven't tried yet. I tried mockk and also tried mockito-kotlin but still couldn't get it working with the instrumentation tests
I think the resource folder should be shared between the to test directories, I tried copying it to the android test directory as well for starters, but then it said for mocking android I should use the mockito-android lib