Unable to run JUnit test with PowerMockRunner

前端 未结 4 986
庸人自扰
庸人自扰 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:15

    There may also exist dependencies on classpath that override a JUnit specific class which contains JUnit's version. This leads to incorrect version comparison results in PowerMock. For instance, I had com.google.android.tools:dx:1.7 on classpath (came from hunspell library). It overrides following method return result:

    junit.runner.Version.id() => "3.8.1"
    

    Usually it should return something like "4.12" or "4.11" etc.

提交回复
热议问题