Mockito can no longer mock nested interface on JDK 16-ea+28 and 17.ea+3
See original GitHub issueAfter upgrading from JDK 16-ea+28 and 17.ea+1 to 16-ea+30 and 17.ea+3, respectively, Mockito can no longer mock an interface that is defined inside another interface:
org.mockito.exceptions.base.MockitoException:
Mockito cannot mock this class: interface org.junit.platform.engine.support.hierarchical.Node$DynamicTestExecutor.
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 : 16
JVM vendor name : Oracle Corporation
JVM vendor version : 16-ea+30-2130
JVM name : OpenJDK 64-Bit Server VM
JVM version : 16-ea+30-2130
JVM info : mixed mode, sharing
OS name : Mac OS X
OS version : 10.16
I tried upgrading to 3.6.48 but it did not resolve the issue.
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (5 by maintainers)
Top Results From Across the Web
Mockito cannot mock this class - java - Stack Overflow
When I updated my Java JDK version to 1.8.0_131 the error disappeared. Share.
Read more >Mockito's Java 8 Features - Baeldung
Overview of Java 8 support in Mockito framework, including Streams and ... MockitoException: Cannot call a real method on java interface.
Read more >MockSettings (Mockito 3.3.3 API) - Javadoc.io
Allows mock creation with additional mock settings. Don't use it too often. Consider writing simple tests that use simple mocks.
Read more >Mockito: Cannot instantiate @InjectMocks field: the type is an ...
Use this annotation on your class under test and Mockito will try to inject mocks either by constructor injection, setter injection, or property ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It is a fix in the JDK, not Byte Buddy.
You are observing this problem: https://github.com/raphw/byte-buddy/issues/991
I am of the opinion that this is a bug in a recent change of OpenJDK but I will await some feedback, worst case I need to adjust Byte Buddy to handle this inconsistency.