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
@InjectMock with reactive RestClient breaks the RestClient for subsequent tests #26594
Comments
/cc @geoand |
1 similar comment
/cc @geoand |
I wouldn't be surprised if this is connected to #26556 (comment) because that test of mine that breaks subsequent tests is using Edit: This doesn't seem to be the case, although it sounded so similar; the reproducer still fails with reverted #26556. |
I'll take a look |
#26597 takes care of the issue |
geoand
added a commit
to geoand/quarkus
that referenced
this issue
Jul 8, 2022
geoand
added a commit
that referenced
this issue
Jul 8, 2022
Clear Reactive REST Client mocks after the test runs
gsmet
pushed a commit
to gsmet/quarkus
that referenced
this issue
Jul 18, 2022
Fixes: quarkusio#26594 (cherry picked from commit d6bdfaa)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
If a RestClient is mocked with
@InjectMock
(fromio.quarkus:quarkus-junit5-mockito
) in a test, the reactive RestClient will not work correctly for subsequent tests without mocks.However, the error occurs only when
io.quarkus:quarkus-rest-client-reactive-jackson
is used. With the classic RestClient (io.quarkus:quarkus-rest-client-jackson
), the RestClient is reset as expected after the tests.Expected behavior
RestClient from
io.quarkus:quarkus-rest-client-reactive-jackson
can be used in different tests both as a mock and without.The order in which the tests are run should not matter either.
The behavior should be the same for
io.quarkus:quarkus-rest-client-reactive-jackson
as forio.quarkus:quarkus-rest-client-jackson
.Actual behavior
After the first QuarkusTest, in which a RestClient is mocked with
@io.quarkus.test.junit.mockito.InjectMock
, the RestClient can no longer be used without a mock.The requests, which are executed over the RestClient, are not executed and an empty response is always returned.
In the tests, which are executed before, the RestClient works as expected.
Subsequent tests, which also use a
@InjectMock
mocked RestClient, also work correctly.How to Reproduce?
Reproducer: https://github.com/vonatzigenc/reproducer_quarkus_reactive_restclient_mockito
./mvnw clean verify
TestWithoutMockAfterUsingInjectMock.testHelloEndpoint
failsDescription of the tests:
TestWithoutMockBeforeUsingInjectMock
TestWithInjectMock
SecondTestWithInjectMock
TestWithoutMockAfterUsingInjectMock
"Workarounds"
io.quarkus:quarkus-rest-client-reactive-jackson
is replaced byio.quarkus:quarkus-rest-client-jackson
all tests pass@InjectMocks
with a custom TestProfile, the tests will passOutput of
uname -a
orver
No response
Output of
java -version
No response
GraalVM version (if different from Java)
No response
Quarkus version or git rev
2.10.2.Final
Build tool (ie. output of
mvnw --version
orgradlew --version
)No response
Additional information
No response
The text was updated successfully, but these errors were encountered: