Mockito extension not working with `@QuarkusTest`
See original GitHub issueDescribe the bug
Having a test with:
@QuarkusTest
@ExtendWith(MockitoExtension.class)
class Test {
@Captor
ArgumentCaptor<Whatever> captor;
}
will not correctly utilize the MockitoExtension
and Mockito annotated fields will not be initialized.
Expected behavior
org.mockito
annotations are correctly initialized
Actual behavior
Seems that Mockito extension is initalizing the fields in the different test instance. Simple debugging I did showed that mockito correctly initialized fields in my test instance {GrpcClientsTest@10823}
, while the actual instance being used in the test is {GrpcClientsTest@10895}
.
How to Reproduce?
No response
Output of uname -a
or ver
Linux ise-Precision-5550 5.13.0-39-generic #44~20.04.1-Ubuntu SMP Thu Mar 24 16:43:35 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
Output of java -version
No response
GraalVM version (if different from Java)
No response
Quarkus version or git rev
2.8.0.Final
Build tool (ie. output of mvnw --version
or gradlew --version
)
pache Maven 3.8.4 (9b656c72d54e5bacbed989b64718c159fe39b537) Maven home: /home/ise/.m2/wrapper/dists/apache-maven-3.8.4-bin/52ccbt68d252mdldqsfsn03jlf/apache-maven-3.8.4 Java version: 17.0.2, vendor: Private Build, runtime: /usr/lib/jvm/java-17-openjdk-amd64 Default locale: en_US, platform encoding: UTF-8 OS name: “linux”, version: “5.13.0-39-generic”, arch: “amd64”, family: “unix”
Additional information
No response
Issue Analytics
- State:
- Created a year ago
- Comments:6 (5 by maintainers)
There are various limitations, yes.
I never said it was a good approach, it was however the only one that allowed us to support the feature set we need.
If JUnit supports loading test classes from a custon ClassLoader in the future (there is an open issue), we could ditch this approach.
It only works for beans