1

Running unit tests locally on Android Studio works fine but when I run it with gradle using ./gradlew test. The tests fails with the exception saying Mockito cannot spy/mock final classes. I thought using mockito with the inline extension was supposed to fix this. I have this dependency in my gradle file testImplementation "org.mockito:mockito-inline:2.18.0"

Is there something that I'm missing?

Jackie Ho
  • 21
  • 2

1 Answers1

0

What helped me, is to create a MockMaker file and to put it into test resources.

File org.mockito.plugins.MockMaker (literally) that contains only this line

mock-maker-inline

and place it into test/resources/mockito-extensions. Answer - https://stackoverflow.com/a/50449830/3569545

Demigod
  • 5,073
  • 3
  • 31
  • 49