我的所有测试都使用“mvn test”命令运行良好。但是,当我使用 eclipse IDE 运行测试时,它不再有效。我收到此异常错误:
org.powermock.reflect.exceptions.FieldNotFoundException: No instance field named "reporter" could be found in the class hierarchy of org.mockito.internal.MockitoCore.
at org.powermock.reflect.internal.matcherstrategies.FieldNameMatcherStrategy.notFound(FieldNameMatcherStrategy.java:40)
at org.powermock.reflect.internal.WhiteboxImpl.findSingleFieldUsingStrategy(WhiteboxImpl.java:501)
at org.powermock.reflect.internal.WhiteboxImpl.findFieldInHierarchy(WhiteboxImpl.java:454)
at org.powermock.reflect.internal.WhiteboxImpl.findFieldInHierarchy(WhiteboxImpl.java:442)
我已经阅读了一些相关主题。似乎是由于某些 junit/powermock 版本兼容性所致: Unable to run JUnit test with PowerMockRunner
但我认为我的版本是正确的:
<junit.version>4.12</junit.version>
<powermock.version>1.7.3</powermock.version>
最佳答案
可能是不兼容的版本。请尝试检查版本:Versions
关于eclipse - 无法在 Eclipse 中使用 PowerMock,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57654777/