Skip to content

Fix JUnit 5 launch failure with standalone/fat Multi-Release JARs#1859

Open
wenytang-ms wants to merge 1 commit intomainfrom
fix/junit5-standalone-jar-launch
Open

Fix JUnit 5 launch failure with standalone/fat Multi-Release JARs#1859
wenytang-ms wants to merge 1 commit intomainfrom
fix/junit5-standalone-jar-launch

Conversation

@wenytang-ms
Copy link
Copy Markdown
Contributor

Summary

Fix JUnit 5 test launch failure when using standalone/fat Multi-Release JARs such as junit-platform-console-standalone-1.13.4.jar.

Problem

Since the upstream Eclipse JDT change (eclipse-jdt/eclipse.jdt.ui@0edde57), CoreTestSearchEngine.findAnnotations() uses NameLookup.findType() with ACCEPT_ANNOTATIONS + checkRestrictions=true instead of the old IJavaProject.findType(). This causes @Testable to not be found in standalone/fat Multi-Release JARs, resulting in:

Cannot find 'org.junit.platform.commons.annotation.Testable' on project build path. JUnit 5 tests can only be run if JUnit 5 is on the build path.

Fix

Override preLaunchCheck() in our JUnitLaunchConfigurationDelegate to:

  1. Call super.preLaunchCheck() normally (preserving all existing validation)
  2. Catch only the specific ERR_JUNIT_NOT_ON_PATH (20006) error
  3. Fall back to IJavaProject.findType() to verify JUnit is actually on the classpath
  4. Only suppress the error if the fallback confirms JUnit is present; otherwise re-throw

This is a narrow, targeted workaround — all other validation from the superclass is preserved.

Related Issues

Override preLaunchCheck() to catch false-negative ERR_JUNIT_NOT_ON_PATH
errors from upstream Eclipse JDT's CoreTestSearchEngine.findAnnotations(),
which fails to find @testable in standalone JARs like
junit-platform-console-standalone-1.13.4.jar.

The fallback uses IJavaProject.findType() (the old-style lookup) to verify
JUnit is actually on the classpath before suppressing the error.

Fixes: redhat-developer/vscode-java#4396
Upstream: eclipse-jdt/eclipse.jdt.ui#2959

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant