Unable to run JUnit test with PowerMockRunner

前端 未结 4 991
庸人自扰
庸人自扰 2020-12-03 09:23

I have a Gradle based Java project were I now want to mock a private method using PowerMock. The problem is that I am not able to use the PowerMockRunner as I always get the

4条回答
  •  孤街浪徒
    2020-12-03 10:16

    This is a bug that occurs when you use JUnit 4.12 and PowerMock < 1.6.1. The problem is solved in PowerMock 1.6.1. Please update your dependencies accordingly

    testCompile 'junit:junit:4.12',
                'org.powermock:powermock-core:1.6.1',
                'org.powermock:powermock-module-junit4:1.6.1',
                'org.powermock:powermock-api-mockito:1.6.1'
    

    If you cannot upgrade PowerMock then you can use JUnit 4.11.

    testCompile 'junit:junit:4.11',
                'org.powermock:powermock-core:1.5.6',
                'org.powermock:powermock-module-junit4:1.5.6',
                'org.powermock:powermock-api-mockito:1.5.6'
    

    Could you please add further lines of the stacktrace, which uncover more details about the problem.

提交回复
热议问题