Skip to content

Conversation

@trancexpress
Copy link
Contributor

@trancexpress trancexpress commented Oct 24, 2025

Fixes: #2559

What it does

How to test

Author checklist

@HannesWell
Copy link
Contributor

Shouldn't this list be extended too:

public static final String JUNIT3_TEST_KIND_ID= "org.eclipse.jdt.junit.loader.junit3"; //$NON-NLS-1$
public static final String JUNIT4_TEST_KIND_ID= "org.eclipse.jdt.junit.loader.junit4"; //$NON-NLS-1$
public static final String JUNIT5_TEST_KIND_ID= "org.eclipse.jdt.junit.loader.junit5"; //$NON-NLS-1$

@trancexpress
Copy link
Contributor Author

Shouldn't this list be extended too:

public static final String JUNIT3_TEST_KIND_ID= "org.eclipse.jdt.junit.loader.junit3"; //$NON-NLS-1$
public static final String JUNIT4_TEST_KIND_ID= "org.eclipse.jdt.junit.loader.junit4"; //$NON-NLS-1$
public static final String JUNIT5_TEST_KIND_ID= "org.eclipse.jdt.junit.loader.junit5"; //$NON-NLS-1$

I checked this too, I have some local changes so far. There are a lot of places where JUNIT5_TEST_KIND_ID is used, introducing JUNIT6_TEST_KIND_ID will need adjustments to those places. I'll push the commit and make the PR a draft PR, since I don't have confidence in all the changes.

One place in particular we decide a test launch is a JUnit 5 test launch based on the test annotation... which is the same in JUnit 6. So no idea what to do with that spot.

@trancexpress trancexpress marked this pull request as draft October 24, 2025 18:08
@eclipse-jdt-bot
Copy link
Contributor

This pull request changes some projects for the first time in this development cycle.
Therefore the following files need a version increment:

org.eclipse.jdt.junit/META-INF/MANIFEST.MF

An additional commit containing all the necessary changes was pushed to the top of this PR's branch. To obtain these changes (for example if you want to push more changes) either fetch from your fork or apply the git patch.

Git patch
From 01841fa08e0dc9b441aa87c78f33ada4b5609a58 Mon Sep 17 00:00:00 2001
From: Eclipse JDT Bot <jdt-bot@eclipse.org>
Date: Fri, 24 Oct 2025 18:11:54 +0000
Subject: [PATCH] Version bump(s) for 4.38 stream


diff --git a/org.eclipse.jdt.junit/META-INF/MANIFEST.MF b/org.eclipse.jdt.junit/META-INF/MANIFEST.MF
index b20dd415e9..3a5dd496a7 100644
--- a/org.eclipse.jdt.junit/META-INF/MANIFEST.MF
+++ b/org.eclipse.jdt.junit/META-INF/MANIFEST.MF
@@ -3,7 +3,7 @@ Automatic-Module-Name: org.eclipse.jdt.junit
 Bundle-ManifestVersion: 2
 Bundle-Name: %pluginName
 Bundle-SymbolicName: org.eclipse.jdt.junit;singleton:=true
-Bundle-Version: 3.17.200.qualifier
+Bundle-Version: 3.17.300.qualifier
 Bundle-Activator: org.eclipse.jdt.internal.junit.ui.JUnitPlugin
 Bundle-ActivationPolicy: lazy
 Bundle-Vendor: %providerName
-- 
2.51.0

Further information are available in Common Build Issues - Missing version increments.

@HannesWell
Copy link
Contributor

One place in particular we decide a test launch is a JUnit 5 test launch based on the test annotation... which is the same in JUnit 6. So no idea what to do with that spot.

The only aproach I can think of at the moment is to somehow inspect what's on the classpath or in the launch-runtime and try to distinguish the available versions.
Of course JDT doesn't know OSGi, Plug-ins and bundles, but the jars added by PDE or the classpath container should still be visible to JDT and of course these jars still have MANIFEST.MF files. And if they are not yet parsed/processed by some other part of JDT, you could still parse them for that purpose.

@trancexpress trancexpress force-pushed the gh2559 branch 4 times, most recently from 9f54bb4 to a020f2e Compare October 27, 2025 16:25
@trancexpress trancexpress marked this pull request as ready for review October 31, 2025 11:03
@trancexpress
Copy link
Contributor Author

trancexpress commented Nov 6, 2025

I'll check tomorrow.

Full error is:

org.eclipse.jdt.junit.tests.TestRunListenerTest5.testThatLauncherLibGetsAdded -- Time elapsed: 0.065 s <<< ERROR!
org.eclipse.core.runtime.AssertionFailedException: org.eclipse.jdt.junit6.runtime is available (required JAR)
        at org.eclipse.jdt.junit.launcher.JUnitLaunchConfigurationDelegate$ClasspathLocalizer.localizeClasspath(JUnitLaunchConfigurationDelegate.java:752)
        at org.eclipse.jdt.junit.launcher.JUnitLaunchConfigurationDelegate.getClasspathAndModulepath(JUnitLaunchConfigurationDelegate.java:700)
        at org.eclipse.jdt.junit.launcher.JUnitLaunchConfigurationDelegate.getVMRunnerConfiguration(JUnitLaunchConfigurationDelegate.java:193)
        at org.eclipse.jdt.junit.launcher.JUnitLaunchConfigurationDelegate.launch(JUnitLaunchConfigurationDelegate.java:278)
        at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:778)
        at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:689)
        at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:684)
        at org.eclipse.jdt.junit.tests.AbstractTestRunListenerTest.launchJUnit(AbstractTestRunListenerTest.java:190)
        at org.eclipse.jdt.junit.tests.AbstractTestRunListenerTest.launchJUnit(AbstractTestRunListenerTest.java:214)
        at org.eclipse.jdt.junit.tests.AbstractTestRunListenerTest.launchJUnit(AbstractTestRunListenerTest.java:210)
        at org.eclipse.jdt.junit.tests.AbstractTestRunListenerTest.launchJUnit(AbstractTestRunListenerTest.java:206)
        at org.eclipse.jdt.junit.tests.TestRunListenerTest5.runSequenceTest(TestRunListenerTest5.java:40)
        at org.eclipse.jdt.junit.tests.TestRunListenerTest5.testThatLauncherLibGetsAdded(TestRunListenerTest5.java:172)
        at java.base/java.lang.reflect.Method.invoke(Method.java:580)
Caused by: java.io.IOException
        at org.eclipse.jdt.junit.launcher.JUnitLaunchConfigurationDelegate$ClasspathLocalizer.localURL(JUnitLaunchConfigurationDelegate.java:798)
        at org.eclipse.jdt.junit.launcher.JUnitLaunchConfigurationDelegate$ClasspathLocalizer.entryString(JUnitLaunchConfigurationDelegate.java:774)
        at org.eclipse.jdt.junit.launcher.JUnitLaunchConfigurationDelegate$ClasspathLocalizer.addEntry(JUnitLaunchConfigurationDelegate.java:761)
        at org.eclipse.jdt.junit.launcher.JUnitLaunchConfigurationDelegate$ClasspathLocalizer.localizeClasspath(JUnitLaunchConfigurationDelegate.java:750)
        ... 13 more

@iloveeclipse
Copy link
Member

iloveeclipse commented Nov 7, 2025

11:00:43  [INFO] --- tycho-apitools:5.0.1-SNAPSHOT:verify (verify) @ org.eclipse.jdt.junit6.runtime ---
11:00:43  [INFO] Resolve API baseline for org.eclipse.jdt:org.eclipse.jdt.junit6.runtime:eclipse-plugin:1.0.0-SNAPSHOT with linux/gtk/x86_64
11:00:43  [INFO] {osgi.os=linux, osgi.ws=gtk, org.eclipse.update.install.features=true, osgi.arch=x86_64, org.eclipse.update.install.sources=true}
11:00:43  [ERROR] Cannot resolve project dependencies:
11:00:43  [ERROR]   You requested to install 'org.eclipse.equinox.p2.iu; org.eclipse.jdt.junit6.runtime 0.0.0, max=2147483647' but it could not be found
11:00:43  [ERROR] 

I will push a fix to master to disable API checks for the new bundle for 4.38.
See #2617

@iloveeclipse
Copy link
Member

The other API errors are due #2600, will be also fixed via #2617

@iloveeclipse
Copy link
Member

Note: I can run JUnit 6 tests with JUnit 6 container if I execute test from Package Explorer. However if I open the launch config, the error is shown in the dialog about missing type Cannot find class 'org.junit.platform.commons.annotation.Testable' on project build path. and launch can't be started:

image

The type is in the JUnit 6 container:

image

@iloveeclipse
Copy link
Member

If you plan to fix something, feel free to rebase on master before pushing to fix API warnings.

The new entry delegates to JUnit 5, since we cant reference
org.eclipse.jdt.junit6.runtime yet.

Fixes: eclipse-jdt#2559
@trancexpress
Copy link
Contributor Author

If you plan to fix something, feel free to rebase on master before pushing to fix API warnings.

Should be fixed now.

I noticed code in org.eclipse.jdt.ui.unittest.junit too, unfortunately I have no idea what UI actions it corresponds to. Any idea what the code in there is for? See: org.eclipse.jdt.ui.unittest.junit.JUnitTestPlugin.JUnitVersion.JUNIT5

@iloveeclipse
Copy link
Member

See also code in PDE that has extra case for JUnit 5 and now probably need to extend it to JUnit 6: org.eclipse.pde.unittest.junit.launcher.JUnitPluginLaunchConfigurationDelegate.internalCollectExecutionArguments(ILaunchConfiguration, List<String>, List<String>)

@iloveeclipse
Copy link
Member

There are two correct API warnings now on https://ci.eclipse.org/jdt/job/eclipse.jdt.ui-github/job/PR-2560/8/apitools/new/ ,

[MANIFEST.MF:6](https://ci.eclipse.org/jdt/job/eclipse.jdt.ui-github/job/PR-2560/8/apitools/new/source.8a3b763b-bc88-4ace-b693-06c1b4b5f5a9/#6) The minor version should be incremented in version 1.2.200, since new APIs have been added since version 1.2.100
[JUnitTestPlugin.java:65](https://ci.eclipse.org/jdt/job/eclipse.jdt.ui-github/job/PR-2560/8/apitools/new/source.000c53a3-1dbf-4112-8391-a1fb4978629f/#65) Missing @since tag on JUNIT6

which are not shown in IDE because of:
This plug-in is not present in the currently active API baseline. org.eclipse.jdt.ui.unittest.junit API Baseline Problem

And that because org.eclipse.jdt.ui.unittest.junit is not in the SDK platform.

Not sure what to do now, if it would be part of SDK it would need proper version bump. I would vote for changing the version as if it would be in the baseline, because it makes sense from consumers point of view, even if it not part of the SDK.

@trancexpress : please try to remove commit 9ca8f50 that increases service version and instead bump version of org.eclipse.jdt.ui.unittest.junit to 1.3.0 (plus add "since" javadoc on new enum value).

@mickaelistria, @jjohnstn , @akurtakov : any idea why org.eclipse.jdt.ui.unittest.junit bundle is not in the SDK (and so not in the API baseline)? It was added at 8a8ff4d. Could it be, it is a deliberate choice?

iloveeclipse added a commit to trancexpress/eclipse.jdt.ui that referenced this pull request Nov 7, 2025
New API was added
org.eclipse.jdt.ui.unittest.junit.JUnitTestPlugin.JUnitVersion.JUNIT6

See eclipse-jdt#2560
iloveeclipse added a commit to trancexpress/eclipse.jdt.ui that referenced this pull request Nov 7, 2025
New API was added
org.eclipse.jdt.ui.unittest.junit.JUnitTestPlugin.JUnitVersion.JUNIT6

See eclipse-jdt#2560
trancexpress pushed a commit to trancexpress/eclipse.jdt.ui that referenced this pull request Nov 7, 2025
New API was added
org.eclipse.jdt.ui.unittest.junit.JUnitTestPlugin.JUnitVersion.JUNIT6

See eclipse-jdt#2560
@trancexpress
Copy link
Contributor Author

I've pushed a fix for this problem: #2618 (comment)

Of the 3 JUnit 5 test cases I've found (I hope there are more), there are still some fails. Potentially we'll have to follow this PR up with fixes.

@trancexpress
Copy link
Contributor Author

@iloveeclipse from my POV we can merge this.

@iloveeclipse iloveeclipse merged commit 9eadf17 into eclipse-jdt:master Nov 7, 2025
13 checks passed
iloveeclipse added a commit that referenced this pull request Nov 7, 2025
New API was added
org.eclipse.jdt.ui.unittest.junit.JUnitTestPlugin.JUnitVersion.JUNIT6

See #2560
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.

Add JUnit 6 test runner selection to JUnit Test launches

4 participants