-
-
Notifications
You must be signed in to change notification settings - Fork 314
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
@Mock default name is not used in failure messages #520
Comments
But a field name should be a Java identifier no? |
It is the generated mock name that does not pass the check for a valid java identifier. Invocation.getMockAndMethodName has 'String mockName = mock.toString();' which gives a default mockName of "EasyMock for ...." which is not a valid java identifier as it include space characters. |
Can you give me a quick test case for that? Because I remember changing something in that realm. So maybe it's fixed now. |
A simple test case with two tests. In both cases the error refers to the failing mock as 'Runnable' instead of 'myRunner1' or 'myRunner2': package test; import org.easymock.EasyMockExtension; @ExtendWith({EasyMockExtension.class})
} |
Although @mock usefully generates a default name for a mock using the field name, this name is not used when reporting failures, for example in verify failures. The issue is in Invocation.getMockAndMethodName which does not use the generated name for the mock if it does not look like a java identifier, which the generated name does not. As a result I believe the value of the @mock facility is reduced because it requires the manual addition of a 'name' attribute to differentiate mocks of the same type which in almost all cases will be the same as the field name.
The text was updated successfully, but these errors were encountered: