Mockito AbstractMethodError on initMocks

前端 未结 5 1499
长发绾君心
长发绾君心 2020-12-17 17:16

So I\'ve been struggling pretty much all day trying to get Mockito to work for my Android project. I added everything to my Gradle build file:

androidTestCom         


        
5条回答
  •  情深已故
    2020-12-17 17:56

    For me it helped switching from mockito to powermock. Downgrading mockito to 1.x gave me the null exception, updgrading to 2.x gave me the AbstractMethodError. Just include in dependencies (instead of mockito):

    testCompile "org.powermock:powermock-module-junit4:1.6.5"
    testCompile "org.powermock:powermock-module-junit4-rule:1.6.5"
    testCompile "org.powermock:powermock-api-mockito:1.6.5"
    testCompile "org.powermock:powermock-classloading-xstream:1.6.5"
    

提交回复
热议问题