I have a Android Clean Architecture project write in Kotlin with 3 modules:
- data (Android Library)
- domaine (Java Library)
- presentation (Android Application)
The 3 modules each have unit tests written with junit. But with Kotlin every class is final by default. I quickly had the problem: How to mock a final class with mockito
It's now possible with Mockito 2
It can be done via the mockito extension mechanism by creating the file /mockito-extensions/org.mockito.plugins.MockMaker
containing a single line:
mock-maker-inline
This solution works very well on data module (Android Library) and presentation module (Android Application) but doesn't work on my domaine module (Java Library).
I know that this question has already been asked (How to mock a final class with mockito, Mock objects calling final classes static methods with Mockito), but I didn't find the answer I'm looking for.