How to mock final class with Mockito 2 on Java Module in Android project?

前端 未结 2 1582
生来不讨喜
生来不讨喜 2020-12-10 20:30

I have a Android Clean Architecture project write in Kotlin with 3 modules:

  • data (Android Library)
  • domaine (Java Library)
  • presentation (Andro
2条回答
  •  一整个雨季
    2020-12-10 21:32

    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.

提交回复
热议问题