由于未发现AbstractCommonPowerMockRunner错误,无法使用PowerMockRunner

时间:2017-08-10 23:42:17

标签: java spring mockito powermock

我正在为一个班级编写单元测试并使用

@RunWith(PowerMockRunner.class). 

我收到不兼容的类型错误

  

"找到org.powermock.modules.junit4.PowerMockRunner但需要org.junit.runner.Runner。"

Gradle依赖项:

testCompile 'org.mockito:mockito-core:2.1.0'
testCompile 'org.powermock:powermock:1.6.1'
testCompile 'org.powermock:powermock-core:1.6.1'
testCompile 'org.powermock:powermock-module-junit4:1.6.2'
testCompile 'org.powermock:powermock-api-mockito:1.6.2'

1 个答案:

答案 0 :(得分:0)

您应该添加到build.gradle

testCompile 'junit:junit:4.12'
testCompile 'org.mockito:mockito-all:1.10.19'
testCompile 'org.powermock:powermock-module-junit4:1.6.6'
testCompile 'org.powermock:powermock-api-mockito:1.6.6'

此处的版本非常重要,因为PowerMock在1.7.0之前不支持mockito 2+