diff --git a/plugins/junit5_rt_tests/test/com/intellij/junit5/JUnitVersionSwitchingIntegrationTest.java b/plugins/junit5_rt_tests/test/com/intellij/junit5/JUnitVersionSwitchingIntegrationTest.java index 6e5ecd6a3296..e8102981f2f0 100644 --- a/plugins/junit5_rt_tests/test/com/intellij/junit5/JUnitVersionSwitchingIntegrationTest.java +++ b/plugins/junit5_rt_tests/test/com/intellij/junit5/JUnitVersionSwitchingIntegrationTest.java @@ -111,7 +111,9 @@ public class JUnitVersionSwitchingIntegrationTest extends AbstractTestFrameworkC ProcessOutput output = doStartTestsProcess(configuration, params -> replaceJUnitVersion(params, JUnitStarter.JUNIT6_PARAMETER)); - assertEmpty(output.err); + + assertTrue("stderr must contain the 'JUnit 6 cannot be used with the current test runtime classpath. Falling back to JUnit 5.' error message", + ContainerUtil.exists(output.err, s -> s.contains("JUnit 6 cannot be used with the current test runtime classpath. Falling back to JUnit 5."))); assertTrue(output.sys.toString().contains("-junit6")); assertTrue("Test output must report that JUnit6 classes are absent (junit6.classes.present=false)", @@ -152,7 +154,9 @@ public class JUnitVersionSwitchingIntegrationTest extends AbstractTestFrameworkC assertNotNull(configuration); ProcessOutput output = doStartTestsProcess(configuration, params -> replaceJUnitVersion(params, JUnitStarter.JUNIT6_PARAMETER)); - assertEmpty(output.err); + + assertTrue("stderr must contain the 'JUnit 6 cannot be used with the current test runtime classpath. Falling back to JUnit 5.' error message", + ContainerUtil.exists(output.err, s -> s.contains("JUnit 6 cannot be used with the current test runtime classpath. Falling back to JUnit 5."))); assertTrue(output.sys.toString().contains("-junit6")); assertTrue("Test output must report that JUnit6 classes are absent (junit6.classes.present=false)", diff --git a/plugins/junit_rt/src/com/intellij/rt/junit/JUnitStarter.java b/plugins/junit_rt/src/com/intellij/rt/junit/JUnitStarter.java index 2d54be8d91f7..465e3814ebf6 100644 --- a/plugins/junit_rt/src/com/intellij/rt/junit/JUnitStarter.java +++ b/plugins/junit_rt/src/com/intellij/rt/junit/JUnitStarter.java @@ -157,6 +157,15 @@ public final class JUnitStarter { switch (runner) { case JUNIT6: if (JUnitRunner.JUNIT6.check()) return JUnitRunner.JUNIT6; + if (JUnitRunner.JUNIT5.check()) { + System.err.println("JUnit 6 cannot be used with the current test runtime classpath. Falling back to JUnit 5."); + System.err.println("If you expected JUnit 6, please check the test runtime dependencies."); + System.err.flush(); + return JUnitRunner.JUNIT5; + } + System.err.println("!!! JUnit Platform is not available on the classpath"); + System.err.flush(); + System.exit(-3); case JUNIT5: if (JUnitRunner.JUNIT5.check()) return JUnitRunner.JUNIT5; System.err.println("!!! JUnit Platform is not available on the classpath");