21
votes

I'm trying to write a unit test using PowerMockRunner but I got the following error:

java.lang.IllegalStateException: Extension API internal error: org.powermock.api.extension.reporter.MockingFrameworkReporterFactoryImpl could not be located in classpath. at org.powermock.tests.utils.impl.AbstractTestSuiteChunkerImpl.getFrameworkReporterFactory(AbstractTestSuiteChunkerImpl.java:190) at org.powermock.modules.junit4.common.internal.impl.JUnit4TestSuiteChunkerImpl.getMockingFrameworkReporter(JUnit4TestSuiteChunkerImpl.java:140) at org.powermock.modules.junit4.common.internal.impl.JUnit4TestSuiteChunkerImpl.run(JUnit4TestSuiteChunkerImpl.java:119) at org.powermock.modules.junit4.common.internal.impl.AbstractCommonPowerMockRunner.run(AbstractCommonPowerMockRunner.java:53) at org.powermock.modules.junit4.PowerMockRunner.run(PowerMockRunner.java:59) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)

I've checked all the dependencies and it's ok, do I need somehthing else?

3

3 Answers

23
votes

After posting the question I found the answer, it seems to be a problem with version 1.6.5, it needs an additional dependency, it's described here.

The dependency is powermock-api-mockito-common version 1.6.5, you can either add it to you pom.xml

<dependency>
    <groupId>org.powermock</groupId>
    <artifactId>powermock-api-mockito-common</artifactId>     
    <version>1.6.5</version>
</dependency>

or download the jar

6
votes

After adding

<dependency>
    <groupId>org.powermock</groupId>
    <artifactId>powermock-api-mockito-common</artifactId>     
    <version>1.6.5</version>
</dependency> 

we are getting - "java.lang.IllegalStateException: Extension API internal error: org.powermock.api.extension.proxyframework.ProxyFrameworkImpl could not be located in class path."

To resolve this issue add below dependency as well -

<dependency>
            <groupId>org.powermock</groupId>
            <artifactId>powermock-api-mockito</artifactId>
            <version>1.5.1</version>
            <scope>test</scope>
</dependency>

now its working fine

4
votes

Following these - http://fewtechissues.blogspot.com/2017/12/mockito-error.html dependencies and versions fixed the issue for me.

<dependency>
    <groupId>org.mockito</groupId>
    <artifactId>mockito-core</artifactId>
    <version>1.10.19</version>
</dependency>
<dependency>
    <groupId>org.powermock</groupId>
    <artifactId>powermock-api-mockito</artifactId>
    <version>1.7.0</version>
    <scope>test</scope>
    <exclusions>
        <exclusion>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
        </exclusion>
    </exclusions>
</dependency>
<dependency>
    <groupId>org.powermock</groupId>
    <artifactId>powermock-module-junit4</artifactId>
    <version>1.7.0</version>
    <scope>test</scope>
</dependency>