Fix JUnit 5 launch failure with standalone/fat Multi-Release JARs#1859
Open
wenytang-ms wants to merge 1 commit intomainfrom
Open
Fix JUnit 5 launch failure with standalone/fat Multi-Release JARs#1859wenytang-ms wants to merge 1 commit intomainfrom
wenytang-ms wants to merge 1 commit intomainfrom
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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()usesNameLookup.findType()withACCEPT_ANNOTATIONS+checkRestrictions=trueinstead of the oldIJavaProject.findType(). This causes@Testableto 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 ourJUnitLaunchConfigurationDelegateto:super.preLaunchCheck()normally (preserving all existing validation)ERR_JUNIT_NOT_ON_PATH(20006) errorIJavaProject.findType()to verify JUnit is actually on the classpathThis is a narrow, targeted workaround — all other validation from the superclass is preserved.
Related Issues