-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Inject mock annotations cleanup #33964
Conversation
mkouba
commented
Jun 12, 2023
- introduce io.quarkus.test.InjectMock
- deprecate io.quakus.test.junit.mockito.InjectMock
- remove io.quarkus.test.component.ConfigureMock
} | ||
current = current.getSuperclass(); | ||
if (!injectMockFields.isEmpty()) { | ||
throw new IllegalStateException( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need this because the @io.quarkus.test.InjectMock
annotation is on the class path even if not supported (i.e. no quarkus-junit5-mockito
dependency)...
I have not been following the latest discussions because I was out for a few days, so I'll let others review before I do |
This looks cool to have a common annotation for mocking. I'm maintaining this project which make it possible to use |
That is a very good question. I don't know. For example, And given the fact that |
🙈 The PR is closed and the preview is expired. |
test-framework/junit5-mockito/src/main/java/io/quarkus/test/junit/mockito/MockitoConfig.java
Outdated
Show resolved
Hide resolved
I think this looks great. Adding the back-link to #33827. Once this merges I'll tidy up my table there. |
FTR I've created #34018 for a common |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
- introduce io.quarkus.test.InjectMock - deprecate io.quakus.test.junit.mockito.InjectMock - remove io.quarkus.test.component.ConfigureMock
This comment has been minimized.
This comment has been minimized.
for (AnnotationInstance instance : instances) { | ||
if (instance.target().kind() != AnnotationTarget.Kind.FIELD) { | ||
continue; | ||
} | ||
if (instance.name().equals(MOCKITO_CONFIG) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there was a typo here maybe this should have been:
if (instance.name().equals(MOCKITO_CONFIG) && instance.target().asField().hasAnnotation(DEPRECATED_INJECT_MOCK)) {
continue;
}
As I think that we shouldn't process @MockConfig
and the deprecated @InjectMock
twice as it sets the same configs, but we should process the @MockConfig
if being used in conjunction with the new @InjectMock
to tweak the mock configuration.
Since now using @MockitoConfig
to convert scopes doesn't work =/
Also saw that there is no test for converting scopes, so this it wasn't caught before.
Good thing is that there is still the deprecated @InjectMock
as we can use it do to scope conversion.