-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incorrect documentation for RETURNS_MOCKS #3285
Comments
I am assuming here that Line 40 in d0a919c
If I understand correctly, we delegate this check to ByteBuddy: mockito/src/main/java/org/mockito/internal/creation/bytebuddy/InlineDelegateByteBuddyMockMaker.java Line 556 in d0a919c
|
Hi @TimvdLippe I just checked that code in InlineDelegateByteBuddyMockMaker:
And INSTRUMENTATION.isModifiableClass(type) returns true for Department. |
Here's Department:
|
Hi
I checked the latest (5.11.0) documentation for Mockito class (https://javadoc.io/static/org.mockito/mockito-core/5.11.0/org/mockito/Mockito.html#23) and it states:
ReturnsMocks first tries to return ordinary values (zeros, empty collections, empty string, etc.) then it tries to return mocks. If the return type cannot be mocked (e.g. is final) then plain null is returned.
I have an enumeration Department with abstract methods (Mockito is unable to mock it). Let's say it's used in OrderRepository:
Then I inject mocked version of OrderRepository:
and when I try to invoke getDepartment():
Department department = orderRepository.getDepartment();
The text was updated successfully, but these errors were encountered: