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 :
I think there is an issue with Mockito version - I just updated the code from -
testCompile group: 'org.mockito', name: 'mockito-all', version: '1.8.5'
to
testCompile group: 'org.mockito', name: 'mockito-all', version: '1.10.19'
Try Cntrl + Shift + T on your eclipse screen. Check what are your results. Ideally eclipse should resolve this class only from one dependency. If you are getting multiple results, you may need to add exclusion on certain dependencies.
Also check if you are able to execute your test cases from command prompt. If you are able to do it, then it's not a maven problem. But if something is failing here, check your dependencies.
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.
Your IDE needs to be synchronized with Maven, which is what you're doing manually by adding the dependencies.
Unfortunately Eclipse doesn't (or didn't) provide this behavior out-of-the-box (unlike IntelliJ which synchronizes seamlessly).
The solution used to be done with the Maven Eclipse Plugin but looking at the docs it seems the latest way to do this is with Eclipse Maven Integration plugin for the IDE.
In case it helps, I faced similar issue in IntelliJ. In principle, the problem is with incorrect mockito jar being picked. How it gets included and how to delete it could be project/IDE specific. My question and answer is here - An exception or error caused a run to abort: org.mockito.internal.progress.ThreadSafeMockingProgress.mockingProgress()L