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
The following piece of code was fine with 4.x (I tried with 4.11.0). However, it throws exception after upgrading to 5.x. I think that's because the totalMemory method is native. However, the exception message doesn't mention that.
org.mockito.exceptions.misusing.MissingMethodInvocationException:
when() requires an argument which has to be 'a method call on a mock'.
For example:
when(mock.getArticles()).thenReturn(articles);
Also, this error might show up because:
1. you stub either of: final/private/equals()/hashCode() methods.
Those methods *cannot* be stubbed/verified.
Mocking methods declared on non-public parent classes is not supported.
2. inside when() you don't call method on mock but on some other object.
at org.example.foo.FooTest.fooTest(FooTest.java:13)
at java.base/java.lang.reflect.Method.invoke(Method.java:580)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
The text was updated successfully, but these errors were encountered:
Note that some configuration are impossible to mock via Mockito
(same as any question on stackoverflow.com)
Problematic version: 5.0.0, 5.10.0
JDK: 17
OS: MacOS
The following piece of code was fine with 4.x (I tried with 4.11.0). However, it throws exception after upgrading to 5.x. I think that's because the
totalMemory
method is native. However, the exception message doesn't mention that.Exception message:
The text was updated successfully, but these errors were encountered: