OpenAPITools / OpenAPITools/openapi-generator

[REQ] A configuration of the JUnit version used for the tests produced by the Java generator

Open
#16,352 12 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Enhancement: Feature
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Is your feature request related to a problem? Please describe.

We are using the Java generator in order to access other REST resources. The generated code also produces JUnit tests (a nice feature to keep our test coverage threshold) but they are designed to use the JUnit 4 library. In our case we only use JUnit 5. At the moment there is no possibility to configure this.

Describe the solution you'd like

The openapi-generator-maven-plugin has already the configuration to turn off the API tests and Model tests (configuration parameters: generateApiTests and generateModelTests). Another configuration to determine the utilized JUnit library in these tests would be nice.

Describe alternatives you've considered

Maybe to supersede the default case of now using JUnit 5 instead of the old JUnit 4 library.

Additional context

In the beginning I have asked at Stackoverflow to get some help and somone mentioned to create a Feature Request here:
https://stackoverflow.com/questions/76920305/generated-test-classes-use-junit-4

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the openapi-generator-maven-plugin configuration and its existing generateApiTests and generateModelTests parameters. Trace how the Java generator produces API and model test classes and identifies their JUnit dependency. Done means generated tests can use a selected JUnit library, including JUnit 4 and JUnit 5, without breaking the existing test-generation options.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
testing, tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.