Mockito cannot mock this class: className #3030
abhishek621
started this conversation in
General
Replies: 2 comments
-
I had the same issue and worked around it by figuring out that the same class was mocked successfully in other places and worked to make my test more similar to those tests (in this case, adding test fixtures). But what exactly fixed the issue (or caused it), no clue. |
Beta Was this translation helpful? Give feedback.
0 replies
-
Experiencing similar issue after upgrading mockito version to 5.x. Not able to solve this. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi Community,
I am trying to mock a class but after running the test its giving me the following error and test is failing:
org.mockito.exceptions.base.MockitoException:
Mockito cannot mock this class: class com.xyz.Xyz.class -->> (class Name)
Mockito can only mock non-private & non-final classes.
If you're not sure why you're getting this error, please report to the mailing list.
Java : 17
JVM vendor name : Eclipse Adoptium
JVM vendor version : 17.0.6+10
JVM name : OpenJDK 64-Bit Server VM
JVM version : 17.0.6+10
JVM info : mixed mode
OS name : Windows 10
OS version : 10.0
How to resolve the issue...
Beta Was this translation helpful? Give feedback.
All reactions