[BUG] Mix of junit4 and junit5 in Java generator 7.5.0
Description
While the model tests use JUnit 5 (import org.junit.jupiter.api.Test) the api tests still use JUnit 4 (import org.junit.Test).
openapi-generator version
7.5.0
OpenAPI declaration file content or url
Any OpenAPI.json should reproduce the problem.
Generation Details
java -jar openapi-generator-cli-7.5.0.jar generate -i ./MyOpenAPI.json -g java -o genc --additional-properties library=native,serializableModel=true,hideGenerationTimestamp=true,useJakartaEe=true
Steps to reproduce
- Generate Java code
-
mvn clean test
Related issues/PRs
n/a
Suggest a fix
Fix the code that generates the API tests.
thanks for reporting the issue. may i know if you've time to contribute a fix with a PR?
Maybe... can't promise anything regarding the timeframe. But 1st of all, here's a simple json to reproduce the issue. MyOpenAPI.json
So I just tested 7.6.0 which contained some of these fixes but I'm still getting test compilation errors like:
[ERROR] /runner/_work/openapi-client-generator-action/openapi-client-generator-action/client_generation_scripts/gen/java/src/test/java/com/jimdo/openapiclientgeneratoractiontestopenapijavawebclientclient/OnboardingDisconnectErrorResponseTest.java:[21,29]
package org.junit.jupiter.api does not exist
...
[ERROR] /runner/_work/openapi-client-generator-action/openapi-client-generator-action/client_generation_scripts/gen/java/src/test/java/com/jimdo/openapiclientgeneratoractiontestopenapijavawebclientclient/OnboardingDisconnectErrorResponseTest.java:[34,6]
cannot find symbol
symbol: class Test
location: class
...
@bijancn may I know which generator/library did you test?
@wing328 yes of course, we are using the docker image openapitools/openapi-generator-cli:7.6.0 with -g java and "--additional-properties=library=webclient". If you can't reproduce this, I can try to make a minimal reproducer from our full setup.
update: filed https://github.com/OpenAPITools/openapi-generator/pull/18741 to fix the issue