扩展API内部错误:org.powermock.api.extension.reporter.MockingFrameworkReporterFactoryImpl

我正在尝试使用PowerMockRunner编写单元测试但是我收到以下错误:

java.lang.IllegalStateException:扩展API内部错误:org.powermock.api.extension.reporter.MockingFrameworkReporterFactoryImpl无法位于类路径中 . 在Org.powermock的org.powermock.tests.utils.impl.AbstractTestSuiteChunkerImpl.getFrameworkReporterFactory(AbstractTestSuiteChunkerImpl.java:190)org.powermock.modules.junit4.common.internal.impl.JUnit4TestSuiteChunkerImpl.getMockingFrameworkReporter(JUnit4TestSuiteChunkerImpl.java:140) org.powermock上的org.powermock.modules.junit4.common.internal.impl.AbstractCommonPowerMockRunner.run(AbstractCommonPowerMockRunner.java:53)中的.modules.junit4.common.internal.impl.JUnit4TestSuiteChunkerImpl.run(JUnit4TestSuiteChunkerImpl.java:119) .modules.junit4.PowerMockRunner.run(PowerMockRunner.java:59)位于org.eclipse.jdt.internal.junit.runner的org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86) .TestExecution.run(TestExecution.java:38)org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests (RemoteTestRunner.java:675)org.eclipse.jdt.internal.junit.ru nner.RemoteTestRunner.run(RemoteTestRunner.java:382)at or.e.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)

我检查了所有依赖项,没关系,我还需要其他东西吗?

回答(3)

2 years ago

在发布问题后,我找到了答案,它似乎是版本1.6.5的问题,它需要一个额外的依赖,它描述here .

依赖是powermock-api-mockito-common version 1.6.5,你可以将它添加到你的pom.xml中

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

或下载jar

2 years ago

添加后

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

我们得到了 - “java.lang.IllegalStateException:Extension API内部错误:org.powermock.api.extension.proxyframework.ProxyFrameworkImpl无法在类路径中找到 . ”

要解决此问题,请添加以下依赖项 -

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

现在它的工作正常

2 years ago

以下 - http://fewtechissues.blogspot.com/2017/12/mockito-error.html依赖项和版本为我解决了这个问题 .

<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>