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

'TestEngine with ID 'junit-jupiter' failed to discover tests' on bump from 5.11.4 to 5.12.0 #4335

Closed
romani opened this issue Feb 22, 2025 · 17 comments

Comments

@romani
Copy link

romani commented Feb 22, 2025

from checkstyle/checkstyle#16393

Steps to reproduce

git clone git@github.com:checkstyle/checkstyle.git
cd checkstyle
git checkout dependabot/maven/junit.version-5.12.0
mvn clean test

Context

  • Used versions (Jupiter/Vintage/Platform): 5.11.4
  • Build Tool/IDE: mvn

Deliverables

[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[ERROR] TestEngine with ID 'junit-jupiter' failed to discover tests
[INFO] 
[INFO] Results:
[INFO] 
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  30.992 s
[INFO] Finished at: 2025-02-22T07:17:02-08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:3.5.2:test (default-test) on project checkstyle: 
[ERROR] 
[ERROR] See checkstyle/checkstyle/target/surefire-reports for the individual test results.
[ERROR] See dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream.
[ERROR] There was an error in the forked process
[ERROR] TestEngine with ID 'junit-jupiter' failed to discover tests
[ERROR] org.apache.maven.surefire.booter.SurefireBooterForkException: There was an error in the forked process
[ERROR] TestEngine with ID 'junit-jupiter' failed to discover tests
[ERROR]         at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:628)
[ERROR]         at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:285)
[ERROR]         at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:250)
[ERROR]         at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeProvider(AbstractSurefireMojo.java:1336)
[ERROR]         at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAfterPreconditionsChecked(AbstractSurefireMojo.java:1134)
[ERROR]         at org.apache.maven.plugin.surefire.AbstractSurefireMojo.execute(AbstractSurefireMojo.java:968)
[ERROR]         at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:126)
[ERROR]         at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2(MojoExecutor.java:328)
[ERROR]         at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute(MojoExecutor.java:316)
[ERROR]         at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
[ERROR]         at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:174)
[ERROR]         at org.apache.maven.lifecycle.internal.MojoExecutor.access$000(MojoExecutor.java:75)
[ERROR]         at org.apache.maven.lifecycle.internal.MojoExecutor$1.run(MojoExecutor.java:162)
[ERROR]         at org.apache.maven.plugin.DefaultMojosExecutionStrategy.execute(DefaultMojosExecutionStrategy.java:39)
[ERROR]         at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:159)
[ERROR]         at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:105)
[ERROR]         at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:73)
[ERROR]         at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:53)
[ERROR]         at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:118)
[ERROR]         at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:261)
[ERROR]         at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:173)
[ERROR]         at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:101)
[ERROR]         at org.apache.maven.cli.MavenCli.execute(MavenCli.java:906)
[ERROR]         at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:283)
[ERROR]         at org.apache.maven.cli.MavenCli.main(MavenCli.java:206)
[ERROR]         at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[ERROR]         at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[ERROR]         at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[ERROR]         at java.base/java.lang.reflect.Method.invoke(Method.java:566)
[ERROR]         at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:255)
[ERROR]         at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:201)
[ERROR]         at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:361)
[ERROR]         at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:314)
[ERROR] 
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 

@mpkorstanje
Copy link
Contributor

You may want to look at these items:

  1. The branch dependabot/maven/junit.version-5.12.0 has been deleted.

  2. Reproducing this manually, the output from the .dump files as mentioned in the error message contains the following (non-essential details omitted):

# Created at 2025-02-22T16:36:55.009
org.junit.platform.commons.JUnitException: TestEngine with ID 'junit-jupiter' failed to discover tests
 ....
Caused by: org.junit.platform.commons.JUnitException: OutputDirectoryProvider not available; probably due to unaligned versions of the junit-platform-engine and junit-platform-launcher jars on the classpath/module path.
....
  1. The checkstyle project is not using the junit-bom to align dependency versions as recommended by the user guide. So it is likely that one of the JUnit extensions pulls in an older version of JUnit.

@romani
Copy link
Author

romani commented Feb 22, 2025

My bad , closing of dependabot's PR , removed branch.
I restored branch in GitHub ui, should be available now.

The checkstyle project is not using the junit-bom

Let me investigate this approach.
We will improve at checkstyle/checkstyle#16396 thanks a lot for suggestion.

@iProdigy
Copy link

iProdigy commented Feb 22, 2025

I had the same issue
org.gradle.api.internal.tasks.testing.TestSuiteExecutionException: Could not complete execution for Gradle Test Executor 5.	
	at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.stop(SuiteTestClassProcessor.java:65)	
	at jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)	
	at java.lang.reflect.Method.invoke(Method.java:580)	
	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)	
	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)	
	at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:33)	
	at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:92)	
	at jdk.proxyXX.$ProxyXX.stop(Unknown Source)	
	at org.gradle.api.internal.tasks.testing.worker.TestWorker$3.run(TestWorker.java:200)	
	at org.gradle.api.internal.tasks.testing.worker.TestWorker.executeAndMaintainThreadName(TestWorker.java:132)	
	at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:103)	
	at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:63)	
	at org.gradle.process.internal.worker.child.ActionExecutionWorker.execute(ActionExecutionWorker.java:56)	
	at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:121)	
	at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:71)	
	at worker.org.gradle.process.internal.worker.GradleWorkerMain.run(GradleWorkerMain.java:69)	
	at worker.org.gradle.process.internal.worker.GradleWorkerMain.main(GradleWorkerMain.java:74)	
Caused by: org.junit.platform.commons.JUnitException: TestEngine with ID 'junit-jupiter' failed to discover tests	
	at org.junit.platform.launcher.core.EngineDiscoveryOrchestrator.discoverEngineRoot(EngineDiscoveryOrchestrator.java:160)	
	at org.junit.platform.launcher.core.EngineDiscoveryOrchestrator.discoverSafely(EngineDiscoveryOrchestrator.java:134)	
	at org.junit.platform.launcher.core.EngineDiscoveryOrchestrator.discover(EngineDiscoveryOrchestrator.java:108)	
	at org.junit.platform.launcher.core.EngineDiscoveryOrchestrator.discover(EngineDiscoveryOrchestrator.java:80)	
	at org.junit.platform.launcher.core.DefaultLauncher.discover(DefaultLauncher.java:110)	
	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:86)	
	at org.junit.platform.launcher.core.DefaultLauncherSession$DelegatingLauncher.execute(DefaultLauncherSession.java:86)	
	at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor$CollectAllTestClassesExecutor.processAllTestClasses(JUnitPlatformTestClassProcessor.java:124)	
	at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor$CollectAllTestClassesExecutor.access$000(JUnitPlatformTestClassProcessor.java:99)	
	at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor.stop(JUnitPlatformTestClassProcessor.java:94)	
	at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.stop(SuiteTestClassProcessor.java:63)	
	at jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)	
	at java.lang.reflect.Method.invoke(Method.java:580)	
	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)	
	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)	
	at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:33)	
	at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:92)	
	at jdk.proxyXX.$ProxyXX.stop(Unknown Source)	
	at org.gradle.api.internal.tasks.testing.worker.TestWorker$3.run(TestWorker.java:200)	
	at org.gradle.api.internal.tasks.testing.worker.TestWorker.executeAndMaintainThreadName(TestWorker.java:132)	
	at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:103)	
	at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:63)	
	at org.gradle.process.internal.worker.child.ActionExecutionWorker.execute(ActionExecutionWorker.java:56)	
	at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:121)	
	at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:71)	
	at worker.org.gradle.process.internal.worker.GradleWorkerMain.run(GradleWorkerMain.java:69)	
	at worker.org.gradle.process.internal.worker.GradleWorkerMain.main(GradleWorkerMain.java:74)	
Caused by: org.junit.platform.commons.JUnitException: OutputDirectoryProvider not available; probably due to unaligned versions of the junit-platform-engine and junit-platform-launcher jars on the classpath/module path.	
	at org.junit.platform.engine.EngineDiscoveryRequest.getOutputDirectoryProvider(EngineDiscoveryRequest.java:94)	
	at org.junit.jupiter.engine.JupiterTestEngine.discover(JupiterTestEngine.java:67)	
	at org.junit.platform.launcher.core.EngineDiscoveryOrchestrator.discoverEngineRoot(EngineDiscoveryOrchestrator.java:152)	
	at org.junit.platform.launcher.core.EngineDiscoveryOrchestrator.discoverSafely(EngineDiscoveryOrchestrator.java:134)	
	at org.junit.platform.launcher.core.EngineDiscoveryOrchestrator.discover(EngineDiscoveryOrchestrator.java:108)	
	at org.junit.platform.launcher.core.EngineDiscoveryOrchestrator.discover(EngineDiscoveryOrchestrator.java:80)	
	at org.junit.platform.launcher.core.DefaultLauncher.discover(DefaultLauncher.java:110)	
	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:86)	
	at org.junit.platform.launcher.core.DefaultLauncherSession$DelegatingLauncher.execute(DefaultLauncherSession.java:86)	
	at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor$CollectAllTestClassesExecutor.processAllTestClasses(JUnitPlatformTestClassProcessor.java:124)	
	at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor$CollectAllTestClassesExecutor.access$000(JUnitPlatformTestClassProcessor.java:99)	
	at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor.stop(JUnitPlatformTestClassProcessor.java:94)	
	at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.stop(SuiteTestClassProcessor.java:63)	
	at jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)	
	at java.lang.reflect.Method.invoke(Method.java:580)	
	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)	
	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)	
	at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:33)	
	at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:92)	
	at jdk.proxyXX.$ProxyXX.stop(Unknown Source)	
	at org.gradle.api.internal.tasks.testing.worker.TestWorker$3.run(TestWorker.java:200)	
	at org.gradle.api.internal.tasks.testing.worker.TestWorker.executeAndMaintainThreadName(TestWorker.java:132)	
	at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:103)	
	at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:63)	
	at org.gradle.process.internal.worker.child.ActionExecutionWorker.execute(ActionExecutionWorker.java:56)	
	at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:121)	
	at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:71)	
	at worker.org.gradle.process.internal.worker.GradleWorkerMain.run(GradleWorkerMain.java:69)	
	at worker.org.gradle.process.internal.worker.GradleWorkerMain.main(GradleWorkerMain.java:74)

I already use junit-bom, but the issue was fixed after I added testRuntimeOnly(group = "org.junit.platform", name = "junit-platform-launcher") (despite running via ./gradlew test rather than an outdated intellij version)

@marcphilipp
Copy link
Member

@iProdigy FWIW, not specifying a testRuntimeOnly dependency on junit-platform-launcher is deprecated since Gradle 8.

@marcphilipp
Copy link
Member

@romani I did a little digging.

It seems in your case the wrong version of junit-platform-launcher gets pulled in via junit-pioneer:

$ mvn dependency:tree
[INFO] --- dependency:3.8.1:tree (default-cli) @ checkstyle ---
...
[INFO] +- org.junit-pioneer:junit-pioneer:jar:2.3.0:test
[INFO] |  +- org.junit.jupiter:junit-jupiter-params:jar:5.11.2:test
[INFO] |  \- org.junit.platform:junit-platform-launcher:jar:1.11.2:test
...

Surefire even resolves the 1.12.0 version of it, but then ends up using 1.11.2 because it's already on the test runtime classpath. Using the BOM is the right solution in this case and generally recommended.

@marcphilipp marcphilipp closed this as not planned Won't fix, can't repro, duplicate, stale Feb 23, 2025
jprinet added a commit to gradle/common-custom-user-data-gradle-plugin that referenced this issue Feb 24, 2025
jprinet added a commit to gradle/common-custom-user-data-gradle-plugin that referenced this issue Feb 24, 2025
* Bump org.junit:junit-bom from 5.11.4 to 5.12.0

Bumps [org.junit:junit-bom](https://github.com/junit-team/junit5) from 5.11.4 to 5.12.0.
- [Release notes](https://github.com/junit-team/junit5/releases)
- [Commits](junit-team/junit5@r5.11.4...r5.12.0)

---
updated-dependencies:
- dependency-name: org.junit:junit-bom
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* Add required dependency on junit-platform-launcher

See junit-team/junit5#4335

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Jerome Prinet <jprinet@gradle.com>
@robseidel
Copy link

If you are using maven, then https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter/5.12.0 does not contain the junit-platform-launcher as dependency. And you will run into this issue when upgrading from 5.11.4 to 5.12.0.

@mpkorstanje
Copy link
Contributor

@robseidel do you have a more precise reproducer? As currently reported using the junit-bom to align dependencies will resolve that.

@robseidel
Copy link

Aligning the boms is not the issue. You need the dependency junit-platform-launcher in your dependency tree, to get OutputDirectoryProvider initialized correctly.

In my project I had used before this dependency, regard to the documentation and example:

	<dependency>
		<groupId>org.junit.jupiter</groupId>
		<artifactId>junit-jupiter</artifactId>
		<version>5.11.4</version>
		<scope>test</scope>
	</dependency>

After updating the version, I'll run into this very issue. The solution is to add the junit-platform-launcher:

	<dependency>
		<groupId>org.junit.jupiter</groupId>
		<artifactId>junit-jupiter</artifactId>
		<version>5.12.0</version>
		<scope>test</scope>
	</dependency>
	<dependency>
		<groupId>org.junit.platform</groupId>
		<artifactId>junit-platform-launcher</artifactId>
		<version>1.12.0</version>
		<scope>test</scope>
	</dependency>

@marcphilipp
Copy link
Member

You need the dependency junit-platform-launcher in your dependency tree, to get OutputDirectoryProvider initialized correctly.

Maven Surefire will automatically add junit-platform-launcher (based on the version of junit-platform-engine) if it's not already present.

@marcphilipp
Copy link
Member

@robseidel I suspect your project is pulling in a different version of junit-platform-launcher via a transitive dependency. Could you please share the output of mvn dependency:tree?

@robseidel
Copy link

robseidel commented Feb 25, 2025

[INFO]   from pom.xml
[INFO] �[1m--------------------------------[ jar ]---------------------------------�[m
[INFO] 
[INFO] �[1m--- �[0;32mdependency:3.6.1:tree�[m �[1m(default-cli)�[m @ �[36mAEBSignature�[0;1m ---�[m
[INFO] de.aeb:MyProject:jar:NIGHTLY_4.4-SNAPSHOT
[INFO] +- org.bouncycastle:bcprov-jdk18on:jar:1.78.1:compile
[INFO] +- org.bouncycastle:bcpkix-jdk18on:jar:1.78.1:compile
[INFO] |  \- org.bouncycastle:bcutil-jdk18on:jar:1.78.1:compile
[INFO] +- org.apache.commons:commons-lang3:jar:3.17.0:compile
[INFO] +- org.apache.commons:commons-compress:jar:1.27.1:compile
[INFO] |  +- commons-codec:commons-codec:jar:1.18.0:compile
[INFO] |  \- commons-io:commons-io:jar:2.18.0:compile
[INFO] +- org.hamcrest:hamcrest:jar:2.2:test
[INFO] +- org.junit.jupiter:junit-jupiter:jar:5.12.0:test
[INFO] |  +- org.junit.jupiter:junit-jupiter-api:jar:5.12.0:test
[INFO] |  |  +- org.opentest4j:opentest4j:jar:1.3.0:test
[INFO] |  |  +- org.junit.platform:junit-platform-commons:jar:1.12.0:test
[INFO] |  |  \- org.apiguardian:apiguardian-api:jar:1.1.2:test
[INFO] |  +- org.junit.jupiter:junit-jupiter-params:jar:5.12.0:test
[INFO] |  \- org.junit.jupiter:junit-jupiter-engine:jar:5.12.0:test
[INFO] |     \- org.junit.platform:junit-platform-engine:jar:1.12.0:test
[INFO] �[1m------------------------------------------------------------------------�[m
[INFO] �[1;32mBUILD SUCCESS�[m
[INFO] �[1m------------------------------------------------------------------------�[m
[INFO] Total time:  1.638 s
[INFO] Finished at: 2025-02-25T10:06:09+01:00
[INFO] �[1m------------------------------------------------------------------------

I'm pretty sure it depends on my surefire configuration. Thats something like:

        <plugin>
          <artifactId>maven-surefire-plugin</artifactId>
          <version>3.2.5</version>
          <dependencies>
            <dependency>
              <groupId>org.apache.maven.surefire</groupId>
              <artifactId>surefire-junit-platform</artifactId>
              <version>3.2.5</version>
            </dependency>
          </dependencies>
          <configuration>
            <includes>
              <include>**/*.java</include>
            </includes>
            <excludeJUnit5Engines>junit-platform-suite</excludeJUnit5Engines>
            <useSystemClassLoader>false</useSystemClassLoader>
          </configuration>
        </plugin>

I've update the versions (3.5.2), but it seems surefire downloaded the wrong launcher version in my case:

[INFO] Downloading from : https://repo.aeb.com:443/artifactory/maven2/org/junit/platform/junit-platform-engine/1.10.3/junit-platform-engine-1.10.3.jar
[INFO] Downloading from : https://repo.aeb.com:443/artifactory/maven2/org/junit/platform/junit-platform-commons/1.10.3/junit-platform-commons-1.10.3.jar
[INFO] Downloading from : https://repo.aeb.com:443/artifactory/maven2/org/junit/platform/junit-platform-launcher/1.10.3/junit-platform-launcher-1.10.3.jar
[DEBUG] Populating class realm plugin>org.apache.maven.plugins:maven-surefire-plugin:3.5.2
[DEBUG]   Included: org.apache.maven.plugins:maven-surefire-plugin:jar:3.5.2
[DEBUG]   Included: org.apache.maven.surefire:surefire-junit-platform:jar:3.5.2
[DEBUG]   Included: org.apache.maven.surefire:common-java5:jar:3.5.2
[DEBUG]   Included: org.apache.maven.surefire:surefire-shared-utils:jar:3.5.2
[DEBUG]   Included: org.junit.platform:junit-platform-engine:jar:1.10.3
[DEBUG]   Included: org.opentest4j:opentest4j:jar:1.3.0
[DEBUG]   Included: org.junit.platform:junit-platform-commons:jar:1.10.3
[DEBUG]   Included: org.apiguardian:apiguardian-api:jar:1.1.2
[DEBUG]   Included: org.junit.platform:junit-platform-launcher:jar:1.10.3
[DEBUG]   Included: org.apache.maven.surefire:surefire-api:jar:3.5.2
[DEBUG]   Included: org.apache.maven.surefire:surefire-logger-api:jar:3.5.2
[DEBUG]   Included: org.apache.maven.surefire:surefire-extensions-api:jar:3.5.2
[DEBUG]   Included: org.apache.maven.surefire:maven-surefire-common:jar:3.5.2
[DEBUG]   Included: org.apache.maven.surefire:surefire-booter:jar:3.5.2
[DEBUG]   Included: org.apache.maven.surefire:surefire-extensions-spi:jar:3.5.2
[DEBUG]   Included: org.apache.maven.shared:maven-common-artifact-filters:jar:3.4.0
[DEBUG]   Included: org.codehaus.plexus:plexus-java:jar:1.3.0
[DEBUG]   Included: org.ow2.asm:asm:jar:9.7
[DEBUG]   Included: com.thoughtworks.qdox:qdox:jar:2.1.0

I've tested in an empty project and as you wrote, surefire downloaded the correct launcher. I'm now using the launcher dependency directly as I don't know how I can influence the downloaded version in case of surefire gets the dependency. Thnx a lot for the information about how the launcher gets downloaded by surefire.

@mpkorstanje
Copy link
Contributor

Declaring a dependency on surefire-junit-platform likely pulls in the older version. And I'm not sure why that is done, or if it is necessary.

@marcphilipp
Copy link
Member

AFAIK that shouldn't be necessary. @robseidel Could you please removing that dependency?

@robseidel
Copy link

@mpkorstanje thnx a lot. This was a relict from some previous projects where Junit4 tests run beside Junit5 tests. I've removed it and now it uses the correct version. Thnx a lot for you help. You're awesome.

violetagg added a commit to reactor/reactor-core that referenced this issue Feb 25, 2025
Add runtime dependency to "org.junit.platform:junit-platform-launcher" as per
junit-team/junit5#4335 (comment)

Signed-off-by: Violeta Georgieva <violeta.georgieva@broadcom.com>
@sormuras sormuras marked this as a duplicate of #4341 Feb 25, 2025
@github-actions github-actions bot marked this as not a duplicate of #4341 Feb 25, 2025
@marcphilipp marcphilipp marked this as a duplicate of #4341 Feb 25, 2025
@github-actions github-actions bot marked this as not a duplicate of #4341 Feb 25, 2025
@marcphilipp marcphilipp marked this as a duplicate of #4341 Feb 25, 2025
chemicL pushed a commit to reactor/reactor-core that referenced this issue Feb 26, 2025
Add runtime dependency to "org.junit.platform:junit-platform-launcher" as per
junit-team/junit5#4335 (comment)

Signed-off-by: Violeta Georgieva <violeta.georgieva@broadcom.com>
@be-hase
Copy link

be-hase commented Mar 3, 2025

@marcphilipp
For reference, I'd like to understand why this behavior change occurred starting from Gradle & JUnit 5.12.

I’m aware that Gradle 8 included this change, but I couldn’t figure out why upgrading JUnit to 5.12 specifically caused this behavioral difference.

If this were caused by upgrading Gradle, I would understand, but what exactly in JUnit 5.12 led to this change?

vlsi added a commit to vlsi/sigstore-java that referenced this issue Mar 3, 2025
Previously, Gradle added the dependency behing the scenes, however it has
been deprecated since 8. Now we should add the dependency explicitly.

See junit-team/junit5#4335 (comment)
vlsi added a commit to vlsi/sigstore-java that referenced this issue Mar 3, 2025
Previously, Gradle added the dependency behing the scenes, however it has
been deprecated since 8. Now we should add the dependency explicitly.

See junit-team/junit5#4335 (comment)

Signed-off-by: Vladimir Sitnikov <sitnikov.vladimir@gmail.com>
@marcphilipp
Copy link
Member

Without an explicit dependency on junit-platform-launcher, Gradle uses whichever version it was released with. As of Gradle 8.13, that's 1.8.2. You can validate that by including the following snipped in your test code.

var launcherVersion = Class.forName("org.junit.platform.launcher.Launcher").getPackage().getImplementationVersion();
System.out.println("launcherVersion = " + launcherVersion);

Class.forName("org.junit.platform.engine.TestEngine").getPackage().getImplementationVersion();
System.out.println("engineVersion = " + engineVersion);

It prints:

launcherVersion = 1.8.2
engineVersion = 1.11.4

That only worked because 1.9.x, 1.10.x, and 1.11.x were fully compatible with each other. However, it's not something we officially support and was bound to break at some point. It's also the reason for Gradle 8 having deprecated not declaring an explicit dependency on junit-platform-launcher that ensures it's aligned because the platform (BOM) gets pulled in via Gradle Module Metadata.

In JUnit 5.12 (which corresponds to Platform version 1.12) a new API (OutputDirectoryProvider) was introduced which engines require the launcher to provide. Therefore, the hidden misalignment issue that was there all along now surfaced.

@marcphilipp
Copy link
Member

PR to improve our docs:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants