question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Mockito can no longer mock nested interface on JDK 16-ea+28 and 17.ea+3

See original GitHub issue

After 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

Gradle build scan: https://ge.junit.org/s/7nva27dj6tilo/tests/:junit-jupiter-engine:test/org.junit.jupiter.engine.descriptor.TestFactoryTestDescriptorTests$Streams/streamsFromTestFactoriesShouldBeClosed()#1

I tried upgrading to 3.6.48 but it did not resolve the issue.

Code is here: https://github.com/junit-team/junit5/blob/5c64fceacb596a182a25853f7fcaeaefe23abfa7/junit-platform-engine/src/main/java/org/junit/platform/engine/support/hierarchical/Node.java#L282

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
raphwcommented, Apr 14, 2021

It is a fix in the JDK, not Byte Buddy.

1reaction
raphwcommented, Jan 1, 2021

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found