Open DanielYWoo opened 4 years ago
Mockito 3.3.2 worked fine for me with PowerMockito 2.0.7, but when upgrading Mockito to 3.4.2 I got (across OpenJDK 8, 11 and 14):
2020-07-17T09:04:15.2938455Z java.lang.NoSuchMethodError: 'void org.powermock.api.mockito.internal.configuration.PowerMockitoInjectingAnnotationEngine.injectMocks(java.lang.Object)' 2020-07-17T09:04:15.2941168Z at org.powermock.api.mockito.internal.configuration.PowerMockitoInjectingAnnotationEngine.process(PowerMockitoInjectingAnnotationEngine.java:40) 2020-07-17T09:04:15.2943601Z at org.powermock.api.extension.listener.AnnotationEnabler.injectSpiesAndInjectToSetters(AnnotationEnabler.java:61) 2020-07-17T09:04:15.2944342Z at org.powermock.api.extension.listener.AnnotationEnabler.beforeTestMethod(AnnotationEnabler.java:56) 2020-07-17T09:04:15.2946765Z at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 2020-07-17T09:04:15.2947337Z at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 2020-07-17T09:04:15.2949524Z at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 2020-07-17T09:04:15.2950118Z at java.base/java.lang.reflect.Method.invoke(Method.java:566) 2020-07-17T09:04:15.2952280Z at org.powermock.reflect.internal.WhiteboxImpl.performMethodInvocation(WhiteboxImpl.java:1863) 2020-07-17T09:04:15.2952796Z at org.powermock.reflect.internal.WhiteboxImpl.invokeMethod(WhiteboxImpl.java:715) 2020-07-17T09:04:15.2954732Z at org.powermock.reflect.Whitebox.invokeMethod(Whitebox.java:415) 2020-07-17T09:04:15.2956466Z at org.powermock.modules.testng.PowerMockTestCase.injectMocks(PowerMockTestCase.java:135) 2020-07-17T09:04:15.2959094Z at org.powermock.modules.testng.PowerMockTestCase.beforePowerMockTestMethod(PowerMockTestCase.java:85) 2020-07-17T09:04:15.2959730Z at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 2020-07-17T09:04:15.2962070Z at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 2020-07-17T09:04:15.2964300Z at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 2020-07-17T09:04:15.2964937Z at java.base/java.lang.reflect.Method.invoke(Method.java:566) 2020-07-17T09:04:15.2967166Z at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:133) 2020-07-17T09:04:15.2969335Z at org.testng.internal.MethodInvocationHelper.invokeMethodConsideringTimeout(MethodInvocationHelper.java:62) 2020-07-17T09:04:15.2970034Z at org.testng.internal.ConfigInvoker.invokeConfigurationMethod(ConfigInvoker.java:340) 2020-07-17T09:04:15.2972392Z at org.testng.internal.ConfigInvoker.invokeConfigurations(ConfigInvoker.java:294) 2020-07-17T09:04:15.2972962Z at org.testng.internal.TestInvoker.runConfigMethods(TestInvoker.java:683) 2020-07-17T09:04:15.2975542Z at org.testng.internal.TestInvoker.invokeMethod(TestInvoker.java:510) 2020-07-17T09:04:15.2976140Z at org.testng.internal.TestInvoker.invokeTestMethod(TestInvoker.java:172) 2020-07-17T09:04:15.2978713Z at org.testng.internal.MethodRunner.runInSequence(MethodRunner.java:46) 2020-07-17T09:04:15.2979324Z at org.testng.internal.TestInvoker$MethodInvocationAgent.invoke(TestInvoker.java:804) 2020-07-17T09:04:15.2979914Z at org.testng.internal.TestInvoker.invokeTestMethods(TestInvoker.java:145) 2020-07-17T09:04:15.2982485Z at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:146) 2020-07-17T09:04:15.2983204Z at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:128) 2020-07-17T09:04:15.2985472Z at java.base/java.util.ArrayList.forEach(ArrayList.java:1540) 2020-07-17T09:04:15.2985987Z at org.testng.TestRunner.privateRun(TestRunner.java:770) 2020-07-17T09:04:15.2986448Z at org.testng.TestRunner.run(TestRunner.java:591) 2020-07-17T09:04:15.2988688Z at org.testng.SuiteRunner.runTest(SuiteRunner.java:402) 2020-07-17T09:04:15.2989208Z at org.testng.SuiteRunner.access$000(SuiteRunner.java:41) 2020-07-17T09:04:15.2989682Z at org.testng.SuiteRunner$SuiteWorker.run(SuiteRunner.java:443) 2020-07-17T09:04:15.2991996Z at org.testng.internal.thread.ThreadUtil.lambda$execute$0(ThreadUtil.java:67) 2020-07-17T09:04:15.2992588Z at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) 2020-07-17T09:04:15.2995129Z at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) 2020-07-17T09:04:15.2995727Z at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) 2020-07-17T09:04:15.2997837Z at java.base/java.lang.Thread.run(Thread.java:834)
See also https://github.com/mockito/mockito/issues/1981, in case it's decided to fix this on the Mockito side.
Maybe fixed by https://github.com/mockito/mockito/pull/1974?
According to https://github.com/powermock/powermock/pull/1049 Mockito 3 is now supported.
Currently I am using Mockito 3.x, the document of PowerMock shows that it's not supported. see https://github.com/powermock/powermock/wiki/mockito We really hope Mockito 3.x can be supported soon