-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Description
I have been using InjectMocks and Spy annotations of mockito for the purpose mocking my objects and it used to work fine. I recently migrated to Java 17 and I am getting "InaccessibleObjectException" for the same test case which used to work in Java 16. On checking more about the same I found that illegal-access flag has been deprecated in java 17 and due to which I am getting this exception.
com.balaji.MyClassTest > calculateTest FAILED
java.lang.ExceptionInInitializerError at MyClassTest.java:57
Caused by: java.lang.reflect.InaccessibleObjectException at MyClassTest.java:57
Is there any alternative way to achieve the similar functionalities of InjectMocks and Spy in mockito ?
Details:
Mockito version: org.mockito:mockito-core:3.9.0
Gradle version: 7.3-rc.1
Java version: 17
Thanks in advance.