Extension API internal error: org.powermock.api.extension.reporter.MockingFrameworkReporterFactoryImpl

2022-09-02 03:32:23

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

java.lang.IllegalStateException: Extension API internal error: org.powermock.api.extension.reporter.MockingFrameworkReporterFactoryImpl 无法位于 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) atorg.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)

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


答案 1

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

依赖项是powermock-api-mockito-common版本1.6.5,您可以将其添加到pom中.xml

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

或下载罐子


答案 2

添加后

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

我们正在得到 - “java.lang.IllegalStateException: Extension API internal error: 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>

现在它工作正常


推荐