cannot resolve symbol PowerMockRunner

Elad Benda2 picture Elad Benda2 · Jul 31, 2014 · Viewed 52.5k times · Source

I'm trying to use Powermock for the first time

I use build.gradle and added:

dependencies {
...
    testCompile 'org.mockito:mockito-all:1.9.5'
    testCompile 'org.powermock:powermock-api-mockito:1.5.5'

}

now I look at my test class which has:

import org.junit.Before;
import org.junit.runner.RunWith;
import org.mockito.Matchers;
import org.powermock.core.classloader.annotations.PrepareForTest;


@RunWith(PowerMockRunner.class)
@PrepareForTest(GeoUtils.class)

and get this error:

@RunWith(PowerMockRunner.class)
             ^
cannot resolve symbol PowerMockRunner 

how come it resolves PrepareForTest and not PowerMockRunner ?

Answer

Balaji Katika picture Balaji Katika · Sep 23, 2014

PowerMockRunner is part of powermock-module-junit4.jar. You need to explicity import this jar

You could specify the dependency for this jar as per your requirement. Refer to this link.