Open ennishol opened 10 months ago
/cc @geoand (testing)
The problem is that Quarkus 3.x is fixating the old subclass
mockmaker, which cannot mock e.g. record
(like you do in your example).
There is a hint and a workaround (!) in the 3.0 migration guide: https://github.com/quarkusio/quarkus/wiki/Migration-Guide-3.0#fixation-of-the-mockito-subclass-mockmaker
FTR, this also happens with Java 17.
@geoand are you planning on supporting the default inline
mockmaker properly? I fear that the issue of Quarkus relying on the old and inferior mockmaker will only become worse.
Until then I think the testing guide should contain a similar hint as the 3.0 migration guide (see above).
@famod but then I will run again in the memory usage problem, right? #31251 I'll give it a try
@famod unfortunately exclusion of mockito-subclass
leads to OOM in integration tests, But at least for unit tests I can use it as a workaround
Right, we'll have to tackle the memory leak at some point and support inline
properly.
FWIW, I was just hit by subclass mock maker limitations when trying to @InjectSpy
a spring-data-jpa JpaRepository
that has a default
method - error from mockito: "Cannot call abstract real method on java object!"
So +1 (again) to move on to inline
.
Could we install a callback somewhere to clean the mocks after test execution?
Describe the bug
After adding
quarkus-junit5-mockito
dependency, tests start to fail withCannot mock/spy class
errorExpected behavior
Test should work
Actual behavior
Tests fail
How to Reproduce?
con-testing.tar.gz
./mvnw quarkus:dev
and pressr
to start testingquarkus-junit5-mockito
is removed with the test using@InjectMock
, the failing tests become greenOutput of
uname -a
orver
No response
Output of
java -version
openjdk version "21.0.1" 2023-10-17 LTS Corretto-21.0.1.12.1 (build 21.0.1+12-LTS)
Quarkus version or git rev
5.6.4
Build tool (ie. output of
mvnw --version
orgradlew --version
)Apache Maven 3.9.6
Additional information
No response