diff --git a/tycho-its/src/test/java/org/eclipse/tycho/test/surefire/JUnit4Test.java b/tycho-its/src/test/java/org/eclipse/tycho/test/surefire/JUnit4Test.java index 269d24877e..46047ef698 100644 --- a/tycho-its/src/test/java/org/eclipse/tycho/test/surefire/JUnit4Test.java +++ b/tycho-its/src/test/java/org/eclipse/tycho/test/surefire/JUnit4Test.java @@ -51,4 +51,19 @@ public void contextClassLoaderTest() throws Exception { } + @Test + public void testDeprecationWarning() throws Exception { + + // verify that JUnit 4 provider shows deprecation warning + Verifier verifier = getVerifier("tycho-surefire-plugin/junit4/bundle.test"); + + verifier.executeGoal("integration-test"); + verifier.verifyErrorFreeLog(); + + // verify the deprecation warning is logged + verifier.verifyTextInLog("The JUnit 4 test framework provider is deprecated"); + verifier.verifyTextInLog("Please migrate to JUnit 5 or use JUnit Vintage"); + + } + } diff --git a/tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/AbstractEclipseTestMojo.java b/tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/AbstractEclipseTestMojo.java index 0f8fc2732c..220c960783 100644 --- a/tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/AbstractEclipseTestMojo.java +++ b/tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/AbstractEclipseTestMojo.java @@ -653,10 +653,15 @@ private EquinoxInstallation createProvisionedInstallation() throws MojoExecution //... if not we notify the caller that nothing has to be done here. return null; } - TestFrameworkProvider provider = providerHelper - .selectProvider(project, getProjectType().getClasspath(DefaultReactorProject.adapt(project)), - getMergedProviderProperties(), providerHint) - .provider(); + ProviderSelection selection = providerHelper.selectProvider(project, + getProjectType().getClasspath(DefaultReactorProject.adapt(project)), + getMergedProviderProperties(), providerHint); + TestFrameworkProvider provider = selection.provider(); + if ("junit4".equals(selection.hint())) { + getLog().warn("The JUnit 4 test framework provider is deprecated and may be removed in a future release. " + + "Please migrate to JUnit 5 or use JUnit Vintage to run JUnit 4 tests. " + + "See https://github.com/eclipse-jdt/eclipse.jdt.ui/issues/2586 for more information."); + } try { PropertiesWrapper wrapper = createSurefireProperties(provider, scanResult); storeProperties(wrapper.getProperties(), surefireProperties); @@ -750,6 +755,11 @@ private EquinoxInstallation createEclipseInstallation() throws MojoExecutionExce TestFrameworkProvider provider = selection.provider(); getLog().info(String.format("Selected test framework %s (%s) with provider %s %s", provider.getType(), provider.getVersion(), selection.hint(), provider.getVersionRange())); + if ("junit4".equals(selection.hint())) { + getLog().warn("The JUnit 4 test framework provider is deprecated and may be removed in a future release. " + + "Please migrate to JUnit 5 or use JUnit Vintage to run JUnit 4 tests. " + + "See https://github.com/eclipse-jdt/eclipse.jdt.ui/issues/2586 for more information."); + } Collection testRequiredPackages = new ArrayList<>(); Set testFrameworkBundles = providerHelper.filterTestFrameworkBundles(provider, pluginArtifacts); for (Artifact artifact : testFrameworkBundles) {