Skip to content
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

[Feature Request] Support JUnit 5 #17445

Closed
dbwiddis opened this issue Feb 24, 2025 · 6 comments
Closed

[Feature Request] Support JUnit 5 #17445

dbwiddis opened this issue Feb 24, 2025 · 6 comments
Assignees
Labels
Build Build Tasks/Gradle Plugin, groovy scripts, build tools, Javadoc enforcement. enhancement Enhancement or improvement to existing feature or request

Comments

@dbwiddis
Copy link
Member

dbwiddis commented Feb 24, 2025

Is your feature request related to a problem? Please describe

Many plugins use JUnit5 for unit testing..

However, OpenSearch is still using JUnit 4, which is the version available in the version catalog:
https://github.com/opensearch-project/OpenSearch/blob/main/gradle/libs.versions.toml#L64

This results in a lot of version bump PR churn.

Describe the solution you'd like

  1. Add (the latest) junit5 version to the version catalog
  2. Add some minimal code somewhere in the OpenSearch repo that will trigger dependabot to keep that version updated.
  3. Consider now, or in the future, making alternative versions of OpenSearch test framework classes that depend on JUnit 5

Related component

Build

Describe alternatives you've considered

  1. We could just add the version to the version catalog. This is a very simple solution that would allow plugins to reduce their version bump PR churn, but would (probably) not automatically update via dependabot.
  2. We could consider updating the OpenSearch test framework classes to depend on JUnit 5 as part of 3.x release

Additional context

Option 3 and alternative 2 are probably not easy, requiring upstream changes:

@dbwiddis dbwiddis added enhancement Enhancement or improvement to existing feature or request untriaged labels Feb 24, 2025
@github-actions github-actions bot added the Build Build Tasks/Gradle Plugin, groovy scripts, build tools, Javadoc enforcement. label Feb 24, 2025
@andrross
Copy link
Member

@dbwiddis I'm all for avoiding the PR churn you highlighted here. I honestly don't know the pros/cons of the solutions you listed.

Would option 2 be something like creating a :test:framework-junit5 module in the core that has a JUnit5 dependency? Plugins could optionally take a dependency on that and there would be a single place where that version would get updated by dependabot. Please feel free to take a stab at prototyping one of these options if it seems feasible.

@andrross
Copy link
Member

Or could we just add a JUnit5 dependency to :test:framework if JUnits 4 and 5 are happy to live side-by-side?

@dbwiddis
Copy link
Member Author

I'll take a stab in my free time at what some of the current uses are and see if I can have a minimal JUnit5 Superclass to give at least some of the benefits.

@dbwiddis dbwiddis self-assigned this Feb 27, 2025
@dbwiddis
Copy link
Member Author

After initial research it may be as simple as just brining in JUnit5 dependency (thus getting the version) and using the vintage engine to run existing JUnit4 code/tests, with no additional tests needed.

@dbwiddis
Copy link
Member Author

Or could we just add a JUnit5 dependency to :test:framework if JUnits 4 and 5 are happy to live side-by-side?

Went with this approach. See https://junit.org/junit5/docs/current/user-guide/#migrating-from-junit4

By adding the "vintage" engine, existing Junit 4 tests/code continue to run and allow a slow migration (or partial migration).

@dbwiddis
Copy link
Member Author

Closing, see discussion on #17745

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Build Build Tasks/Gradle Plugin, groovy scripts, build tools, Javadoc enforcement. enhancement Enhancement or improvement to existing feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants