I am trying to move to power mock 2.0.2 and mockito 2.0. Previously I used powermock to mock some local variables: I used on test class
@RunWith(PowerMockRunner.class) @PrepareForTest({MyClass.class}) whenNew(MyClass.class).withAnyArguments().thenReturn(myClassMock); All is fine with Power mock 1.6.. When I tried to move to Powermock 2.x I can not find anymore the whenNew() method in PowerMock. How this changed in the new Powermock? Dependencies:
<dependency> <groupId>org.powermock</groupId> <artifactId>powermock-module-junit4</artifactId> <version>2.0.4</version> <scope>test</scope> </dependency> <dependency> <groupId>org.powermock</groupId> <artifactId>powermock-api-mockito</artifactId> <version>2.0.4</version> <scope>test</scope> </dependency> <dependency> <groupId>org.mockito</groupId> <artifactId>mockito-core</artifactId> <version>2.15.0</version> <scope>test</scope> </dependency> And by the way which version of mockito is compatible wit Powermock? - i see there are some problems of support of Powermock with mockito
whenNewmethod is still in thePowerMockitoclass. You probably have some issues with your dependencies. What is the mockito version you are trying to use? Afaik for 2.0 only beta versions exists and not all of them are supported by powermockito (check thewiki).