我第一次尝试使用Powermock
我使用build.gradle并添加:
dependencies { ... testCompile 'org.mockito:mockito-all:1.9.5' testCompile 'org.powermock:powermock-api-mockito:1.5.5' }
现在我看看我的测试类,它有:
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)
并得到这个错误:
@RunWith(PowerMockRunner.class) ^ cannot resolve symbol PowerMockRunner
如何解决PrepareForTest而不是PowerMockRunner?
解决方法
您需要导入PowerMockRunner如下:
import org.powermock.modules.junit4.PowerMockRunner;