mockito test gives no such method error when run as junit test but when jars are added manually in run confugurations, it runs well

后端 未结 5 1821
予麋鹿
予麋鹿 2020-12-05 18:15

I\'ve been facing a peculiar problem. Basically, when I run my Mockito/PowerMockito test normally i.e. \'Run as Junit Test\', it gives me the following error :



        
5条回答
  •  时光说笑
    2020-12-05 19:06

    For me mockito version was creating issues. Just remove mockito dependency if you have added explicitly in your pom file. I just removed -

    testCompile 'org.mockito:mockito-all:1.9.5' 
    

    line from my gradle file. Lets power mock resolve and add mockito dependency it needs on it's own instead of you forcefully adding one which may led to conflict.

    So for me dependencies are -

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

    other than junit and other lib dependencies you may have.

提交回复
热议问题