Search code examples
mavenjunitmockitopowermockpowermockito

PowerMockito in maven


I want to use PowerMockito in my test to mock static classes, I've imported:

 <dependency>
            <groupId>org.powermock</groupId>
            <artifactId>powermock-module-junit4</artifactId>
            <version>2.0.9</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.powermock</groupId>
            <artifactId>powermock-core</artifactId>
            <version>2.0.9</version>
            <scope>test</scope>
        </dependency>

but even though I have this message: Cannot resolve symbol 'PowerMockito'


Solution

  • You may miss the correct dependency.

    <dependency>
        <groupId>org.powermock</groupId>
        <artifactId>powermock-api-mockito2</artifactId>
        <version>2.0.9</version>
        <scope>test</scope>
    </dependency>