You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, i am getting below error when i am using jdk19, i tried using --add-opens=java.base/java.util.concurrent=ALL-UNNAMED but that also not helping resolve below issue, any suggestion how i can mock ThreadLocalRandom when using jdk19, i am not getting any error if i use jdk17 or below version. Below is the code that generates this error.
final ThreadLocalRandom random = Mockito.mock(ThreadLocalRandom.class);
Mockito.when(random.nextInt(Mockito.anyInt())).thenReturn(0);
Unfortunately, ThreadLocalRandom is one of the classes that Mockito relies on internally for its behavior. Stubbing ThreadLocalRandom will therefore lead to undefined behavior. Additionally, it is advised not to mock classes you don't own: https://github.com/mockito/mockito/wiki/How-to-write-good-tests#dont-mock-a-type-you-dont-own We are working on improving the user experience by working on a DoNotMock feature to avoid mocking classes/methods that are known to crash Mockito internals (#1833). Therefore, I am closing this as "Infeasible". Apologies for the uninformative exception that is thrown.
Hi, i am getting below error when i am using jdk19, i tried using --add-opens=java.base/java.util.concurrent=ALL-UNNAMED but that also not helping resolve below issue, any suggestion how i can mock ThreadLocalRandom when using jdk19, i am not getting any error if i use jdk17 or below version. Below is the code that generates this error.
final ThreadLocalRandom random = Mockito.mock(ThreadLocalRandom.class);
Mockito.when(random.nextInt(Mockito.anyInt())).thenReturn(0);
[ERROR] Failures:
[ERROR] Mockito
Cannot mock/spy class java.util.concurrent.ThreadLocalRandom
Mockito cannot mock/spy following:
The text was updated successfully, but these errors were encountered: