Mockito object is not an instance of declaring class

后端 未结 3 1358
太阳男子
太阳男子 2020-12-17 16:12

I haven\'t touched Mockito for a while, and I have never used it extensively. But today in some new code I wanted to use best practices so I pulled out mockito-core 2.0.54-b

相关标签:
3条回答
  • 2020-12-17 16:38

    If this is helpful to anyone, I got the same above issue and tried all other options like upgrading the JVM etc, but what solved my issue is : https://github.com/mockito/mockito/issues/1606

    By and large reverting my mockito version to 2.23.+ solved the issue for me.

    0 讨论(0)
  • 2020-12-17 16:47

    Had the same issue with my project and used the Rincl project above to confirm I was having the same issue. Using JDK 1.8.0_11 on Mac the reported errors were the same as Garret. Updating to version JDK 1.8.0_181 I ran the Rincl test with NO errors. Apparently Mockito is using the latest of the JDK 1.8.0.

    0 讨论(0)
  • 2020-12-17 16:56

    Your Java runtime version is from March 2014; plenty of bugs have been fixed in the VM ever since and you should really upgrade. I am 99% sure that this problem is related to type annotations (@NonNull) which were introduced in this version for the first time in this exact release. I am sure that your problem will go away if you upgrade your VM.

    I can successfully execute your proposed test with a recent build of the HotSpot VM.

    0 讨论(0)
提交回复
热议问题