Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # 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 · 22 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.

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:

@be-hase
Copy link

be-hase commented Mar 4, 2025

@marcphilipp
Thank you for the detailed explanation! Thanks to you, I was able to understand it! 😊

@abuech2s
Copy link

I got the same exception using Maven 3.9.9 and switching from Junit 5.11.4 to 5.12.1
Do you have any advice, what I should add (dependency, etc.) to get rid of the misbehaviour?

In my pom.xml there are

    <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter-api</artifactId>
        <version>5.12.1</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter-engine</artifactId>
        <version>5.12.1</version>
        <scope>test</scope>
    </dependency>

Furthermore maven-surefire-plugin and maven-failsafe-plugin are integrated as a plugin with version 2.22.2

Thanks

@mpkorstanje
Copy link
Contributor

You'll want to read https://junit.org/junit5/docs/current/user-guide/#running-tests-build-maven

@slessard
Copy link

I still have this problem even after using the BOM and recent releases of surefire and failsafe plugins.

In dependencyManagement I've added

      <dependency>
        <groupId>org.junit</groupId>
        <artifactId>junit-bom</artifactId>
        <version>5.12.1</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>

and removed all other JUnit entries from dependencyManagement

In pluginManagement I'm using

                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>3.3.1</version>
                    <dependencies>
                        <dependency>
                            <groupId>org.apache.maven.surefire</groupId>
                            <artifactId>surefire-junit-platform</artifactId>
                            <version>3.3.1</version>
                        </dependency>
                    </dependencies>
                    <configuration>
                    	<excludes>
                        	<exclude>**/*IT.java</exclude>
                        	<exclude>**/*IntegrationTest.java</exclude>
                      	</excludes>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-failsafe-plugin</artifactId>
                    <version>3.3.1</version>
                    <dependencies>
                        <dependency>
                            <groupId>org.apache.maven.surefire</groupId>
                            <artifactId>surefire-junit-platform</artifactId>
                            <version>3.3.1</version>
                        </dependency>
                    </dependencies>
                    <configuration>
                        <includes>
                            <include>**/*IT.java</include>
                            <include>**/*IntegrationTest.java</include>
                        </includes>
                    </configuration>
                    <executions>
                        <execution>
                            <id>integration-test</id>
                            <goals>
                                <goal>integration-test</goal>
                                <goal>verify</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>

Like others have suggested the only workaround I've found is to add this to dependencies (not dependencyManagement)

    <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter-api</artifactId>
        <version>5.12.1</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter-engine</artifactId>
        <version>5.12.1</version>
        <scope>test</scope>
    </dependency>

@sbrannen
Copy link
Member

I still have this problem even after using the BOM and recent releases of surefire and failsafe plugins.

@slessard, why are you using Surefire 3.3.1 instead of 3.5.3?

Also, why are you explicitly configuring the surefire-junit-platform artifact?

Have you read the corresponding documentation and examples?

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

No branches or pull requests

9 participants