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
I missed the part where you defined the old api component, try powermock-api-mockito2.
 This is what I use in one of my projects (which defaults to mockito-core 2.28.2)
<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-mockito2</artifactId>
        <version>2.0.4</version>
        <scope>test</scope>
    </dependency>
     <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.12</version>
        <scope>test</scope>
    </dependency>
</dependencies>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With