diff --git a/tycho-its/projects/surefire.junit59suite/bundle.test/META-INF/MANIFEST.MF b/tycho-its/projects/surefire.junit59suite/bundle.test/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..8f9088e1f0 --- /dev/null +++ b/tycho-its/projects/surefire.junit59suite/bundle.test/META-INF/MANIFEST.MF @@ -0,0 +1,8 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: JUnit5 Suite Test Plug-in +Bundle-SymbolicName: bundle.test.junit59suite +Bundle-Version: 1.0.0 +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 +Import-Package: org.junit.jupiter.api;version="5.9.0", + org.junit.platform.suite.api;version="1.9.0" diff --git a/tycho-its/projects/surefire.junit59suite/bundle.test/build.properties b/tycho-its/projects/surefire.junit59suite/bundle.test/build.properties new file mode 100644 index 0000000000..34d2e4d2da --- /dev/null +++ b/tycho-its/projects/surefire.junit59suite/bundle.test/build.properties @@ -0,0 +1,4 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + . diff --git a/tycho-its/projects/surefire.junit59suite/bundle.test/pom.xml b/tycho-its/projects/surefire.junit59suite/bundle.test/pom.xml new file mode 100644 index 0000000000..a1dc655921 --- /dev/null +++ b/tycho-its/projects/surefire.junit59suite/bundle.test/pom.xml @@ -0,0 +1,37 @@ + + + 4.0.0 + org.eclipse.tycho.tycho-its.surefire-junit5 + bundle.test.junit59suite + eclipse-test-plugin + 1.0.0 + + + + eclipse + p2 + ${target-platform} + + + + + + + org.eclipse.tycho + tycho-maven-plugin + ${tycho-version} + true + + + org.eclipse.tycho + tycho-surefire-plugin + ${tycho-version} + + + **/SuiteWithAllTests.java + + + + + + diff --git a/tycho-its/projects/surefire.junit59suite/bundle.test/src/bundle/test/JUnit59Test.java b/tycho-its/projects/surefire.junit59suite/bundle.test/src/bundle/test/JUnit59Test.java new file mode 100644 index 0000000000..0b4f84bd06 --- /dev/null +++ b/tycho-its/projects/surefire.junit59suite/bundle.test/src/bundle/test/JUnit59Test.java @@ -0,0 +1,28 @@ +/******************************************************************************* + * Copyright (c) 2023 Vector Informatik GmbH and others. + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Vector Informatik GmbH - initial API and implementation + *******************************************************************************/ +package bundle.test; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; + +class JUnit59Test { + + @Test + @DisplayName("started from test suite") + void startedFromSuite() { + assertEquals(2, 1 + 1); + } + +} diff --git a/tycho-its/projects/surefire.junit59suite/bundle.test/src/bundle/test/SuiteWithAllTests.java b/tycho-its/projects/surefire.junit59suite/bundle.test/src/bundle/test/SuiteWithAllTests.java new file mode 100644 index 0000000000..e1ddf2b6df --- /dev/null +++ b/tycho-its/projects/surefire.junit59suite/bundle.test/src/bundle/test/SuiteWithAllTests.java @@ -0,0 +1,22 @@ +/******************************************************************************* + * Copyright (c) 2023 Vector Informatik GmbH and others. + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Vector Informatik GmbH - initial API and implementation + *******************************************************************************/ +package bundle.test; + +import org.junit.platform.suite.api.Suite; +import org.junit.platform.suite.api.SelectClasses; + +@Suite +@SelectClasses({ JUnit59Test.class }) +public class SuiteWithAllTests { + +} diff --git a/tycho-its/src/test/java/org/eclipse/tycho/test/surefire/JUnit5Test.java b/tycho-its/src/test/java/org/eclipse/tycho/test/surefire/JUnit5Test.java index 9adde2dfda..9ff0101dfd 100644 --- a/tycho-its/src/test/java/org/eclipse/tycho/test/surefire/JUnit5Test.java +++ b/tycho-its/src/test/java/org/eclipse/tycho/test/surefire/JUnit5Test.java @@ -93,4 +93,17 @@ public void testJUnit59Runner() throws Exception { // make sure test tagged as 'slow' was skipped assertNumberOfSuccessfulTests(projectBasedir, "bundle.test.JUnit59Test", 4); } + + @Test + public void testJUnit59Suite() throws Exception { + final Verifier verifier = getVerifier("/surefire.junit59suite/bundle.test"); + verifier.executeGoal("verify"); + verifier.verifyErrorFreeLog(); + final String projectBasedir = verifier.getBasedir(); + assertTestMethodWasSuccessfullyExecuted(projectBasedir, "SuiteWithAllTests", "bundle.test.JUnit59Test", + "started from test suite"); + // make sure tests from suite were executed + assertNumberOfSuccessfulTests(projectBasedir, "bundle.test.JUnit59Test", 1); + } + } diff --git a/tycho-its/src/test/java/org/eclipse/tycho/test/util/SurefireUtil.java b/tycho-its/src/test/java/org/eclipse/tycho/test/util/SurefireUtil.java index 634df79318..134cf03888 100644 --- a/tycho-its/src/test/java/org/eclipse/tycho/test/util/SurefireUtil.java +++ b/tycho-its/src/test/java/org/eclipse/tycho/test/util/SurefireUtil.java @@ -35,11 +35,23 @@ public static File testResultFile(String baseDir, String testSuffix) { public static void assertTestMethodWasSuccessfullyExecuted(String baseDir, String className, String methodName, int iterations) throws Exception { - File resultFile = getTestResultFile(baseDir, className); - Document document = readDocument(resultFile); + assertTestMethodWasSuccessfullyExecuted(baseDir, className, className, methodName, iterations); + } + + public static void assertTestMethodWasSuccessfullyExecuted(String baseDir, String suiteClassSimpleName, + String testClassQualifiedName, String methodName) throws Exception { + String testClassSimpleName = testClassQualifiedName.substring(testClassQualifiedName.lastIndexOf(".") + 1); + assertTestMethodWasSuccessfullyExecuted(baseDir, testClassQualifiedName, + String.join(" ", suiteClassSimpleName, testClassSimpleName), methodName, 1); + } + + private static void assertTestMethodWasSuccessfullyExecuted(String baseDir, String qualifiedClassName, + String classNameInReport, String methodName, int iterations) throws Exception { // surefire-test-report XML schema: // https://maven.apache.org/surefire/maven-surefire-plugin/xsd/surefire-test-report.xsd - String testCaseXPath = String.format("/testsuite/testcase[@classname='%s' and @name='%s']", className, + File resultFile = getTestResultFile(baseDir, qualifiedClassName); + Document document = readDocument(resultFile); + String testCaseXPath = String.format("/testsuite/testcase[@classname='%s' and @name='%s']", classNameInReport, methodName); List testCaseNodes2 = XMLTool.getMatchingNodes(document, testCaseXPath); assertEquals(resultFile.getAbsolutePath() + " with xpath " + testCaseXPath diff --git a/tycho-surefire/org.eclipse.tycho.surefire.junit58/bnd.bnd b/tycho-surefire/org.eclipse.tycho.surefire.junit58/bnd.bnd index 44bfb51dc6..f3c92316bc 100644 --- a/tycho-surefire/org.eclipse.tycho.surefire.junit58/bnd.bnd +++ b/tycho-surefire/org.eclipse.tycho.surefire.junit58/bnd.bnd @@ -1,5 +1,6 @@ Import-Package: \ org.junit.jupiter.api.*;version='[5.8,5.9)',\ + org.junit.platform.suite.api;resolution:=optional;version='[1.8,1.9)',\ org.opentest4j;version='[1.2,2)',\ !org.apache.maven.surefire.*,\ !org.apache.maven.plugin.surefire.*,\ diff --git a/tycho-surefire/org.eclipse.tycho.surefire.junit58/pom.xml b/tycho-surefire/org.eclipse.tycho.surefire.junit58/pom.xml index d6c8650fbb..de04cce985 100644 --- a/tycho-surefire/org.eclipse.tycho.surefire.junit58/pom.xml +++ b/tycho-surefire/org.eclipse.tycho.surefire.junit58/pom.xml @@ -62,6 +62,21 @@ junit-jupiter-engine ${junit-jupiter-version} + + org.junit.platform + junit-platform-suite-api + ${junit-platform-version} + + + org.junit.platform + junit-platform-suite-commons + ${junit-platform-version} + + + org.junit.platform + junit-platform-suite-engine + ${junit-platform-version} + org.apache.maven.surefire common-java5 diff --git a/tycho-surefire/org.eclipse.tycho.surefire.junit58/src/main/resources/META-INF/services/org.junit.platform.engine.TestEngine b/tycho-surefire/org.eclipse.tycho.surefire.junit58/src/main/resources/META-INF/services/org.junit.platform.engine.TestEngine index f19e876790..5ec9a2def9 100644 --- a/tycho-surefire/org.eclipse.tycho.surefire.junit58/src/main/resources/META-INF/services/org.junit.platform.engine.TestEngine +++ b/tycho-surefire/org.eclipse.tycho.surefire.junit58/src/main/resources/META-INF/services/org.junit.platform.engine.TestEngine @@ -1 +1,2 @@ org.junit.jupiter.engine.JupiterTestEngine +org.junit.platform.suite.engine.SuiteTestEngine \ No newline at end of file diff --git a/tycho-surefire/org.eclipse.tycho.surefire.junit58withvintage/bnd.bnd b/tycho-surefire/org.eclipse.tycho.surefire.junit58withvintage/bnd.bnd index c2d08524ef..c3746bc107 100644 --- a/tycho-surefire/org.eclipse.tycho.surefire.junit58withvintage/bnd.bnd +++ b/tycho-surefire/org.eclipse.tycho.surefire.junit58withvintage/bnd.bnd @@ -1,5 +1,6 @@ Import-Package: \ org.junit.jupiter.api.*;version='[5.8,5.9)',\ + org.junit.platform.suite.api;resolution:=optional;version='[1.8,1.9)',\ org.junit.runner.*;resolution:=optional;version='[4.12,5)',\ org.junit.runners.*;resolution:=optional;version='[4.12,5)',\ org.junit.experimental.categories;resolution:=optional;version='[4.12,5)',\ diff --git a/tycho-surefire/org.eclipse.tycho.surefire.junit58withvintage/pom.xml b/tycho-surefire/org.eclipse.tycho.surefire.junit58withvintage/pom.xml index 70eb66ec8b..759ac32bab 100644 --- a/tycho-surefire/org.eclipse.tycho.surefire.junit58withvintage/pom.xml +++ b/tycho-surefire/org.eclipse.tycho.surefire.junit58withvintage/pom.xml @@ -72,6 +72,21 @@ junit-vintage-engine ${junit-jupiter-version} + + org.junit.platform + junit-platform-suite-api + ${junit-platform-version} + + + org.junit.platform + junit-platform-suite-commons + ${junit-platform-version} + + + org.junit.platform + junit-platform-suite-engine + ${junit-platform-version} + org.opentest4j opentest4j diff --git a/tycho-surefire/org.eclipse.tycho.surefire.junit58withvintage/src/main/resources/META-INF/services/org.junit.platform.engine.TestEngine b/tycho-surefire/org.eclipse.tycho.surefire.junit58withvintage/src/main/resources/META-INF/services/org.junit.platform.engine.TestEngine index 4e28d5caa6..1e3bab1293 100644 --- a/tycho-surefire/org.eclipse.tycho.surefire.junit58withvintage/src/main/resources/META-INF/services/org.junit.platform.engine.TestEngine +++ b/tycho-surefire/org.eclipse.tycho.surefire.junit58withvintage/src/main/resources/META-INF/services/org.junit.platform.engine.TestEngine @@ -1,4 +1,5 @@ # Manual merge of META-INF/services/org.junit.platform.engine.TestEngine of both junit-vintage-engine and junit-jupiter-engine # otherwise only one of the two files would win when extracting dependencies org.junit.jupiter.engine.JupiterTestEngine -org.junit.vintage.engine.VintageTestEngine \ No newline at end of file +org.junit.vintage.engine.VintageTestEngine +org.junit.platform.suite.engine.SuiteTestEngine diff --git a/tycho-surefire/org.eclipse.tycho.surefire.junit59/bnd.bnd b/tycho-surefire/org.eclipse.tycho.surefire.junit59/bnd.bnd index 9470f7a290..2266fb2466 100644 --- a/tycho-surefire/org.eclipse.tycho.surefire.junit59/bnd.bnd +++ b/tycho-surefire/org.eclipse.tycho.surefire.junit59/bnd.bnd @@ -1,5 +1,6 @@ Import-Package: \ org.junit.jupiter.api.*;version='[5.9,6)',\ + org.junit.platform.suite.api;resolution:=optional;version='[1.9,2)',\ org.opentest4j;version='[1.2,2)',\ !org.apache.maven.surefire.*,\ !org.apache.maven.plugin.surefire.*,\ diff --git a/tycho-surefire/org.eclipse.tycho.surefire.junit59/pom.xml b/tycho-surefire/org.eclipse.tycho.surefire.junit59/pom.xml index 1b3046ca0c..1d02c233c7 100644 --- a/tycho-surefire/org.eclipse.tycho.surefire.junit59/pom.xml +++ b/tycho-surefire/org.eclipse.tycho.surefire.junit59/pom.xml @@ -62,6 +62,21 @@ junit-jupiter-engine ${junit-jupiter-version} + + org.junit.platform + junit-platform-suite-api + ${junit-platform-version} + + + org.junit.platform + junit-platform-suite-commons + ${junit-platform-version} + + + org.junit.platform + junit-platform-suite-engine + ${junit-platform-version} + org.apache.maven.surefire common-java5 diff --git a/tycho-surefire/org.eclipse.tycho.surefire.junit59/src/main/resources/META-INF/services/org.junit.platform.engine.TestEngine b/tycho-surefire/org.eclipse.tycho.surefire.junit59/src/main/resources/META-INF/services/org.junit.platform.engine.TestEngine index f19e876790..5ec9a2def9 100644 --- a/tycho-surefire/org.eclipse.tycho.surefire.junit59/src/main/resources/META-INF/services/org.junit.platform.engine.TestEngine +++ b/tycho-surefire/org.eclipse.tycho.surefire.junit59/src/main/resources/META-INF/services/org.junit.platform.engine.TestEngine @@ -1 +1,2 @@ org.junit.jupiter.engine.JupiterTestEngine +org.junit.platform.suite.engine.SuiteTestEngine \ No newline at end of file diff --git a/tycho-surefire/org.eclipse.tycho.surefire.junit59withvintage/bnd.bnd b/tycho-surefire/org.eclipse.tycho.surefire.junit59withvintage/bnd.bnd index 75e44c3d16..e8466702ae 100644 --- a/tycho-surefire/org.eclipse.tycho.surefire.junit59withvintage/bnd.bnd +++ b/tycho-surefire/org.eclipse.tycho.surefire.junit59withvintage/bnd.bnd @@ -1,5 +1,6 @@ Import-Package: \ org.junit.jupiter.api.*;version='[5.9,6)',\ + org.junit.platform.suite.api;resolution:=optional;version='[1.9,2)',\ org.junit.runner.*;resolution:=optional;version='[4.12,5)',\ org.junit.runners.*;resolution:=optional;version='[4.12,5)',\ org.junit.experimental.categories;resolution:=optional;version='[4.12,5)',\ diff --git a/tycho-surefire/org.eclipse.tycho.surefire.junit59withvintage/pom.xml b/tycho-surefire/org.eclipse.tycho.surefire.junit59withvintage/pom.xml index c70641b2c3..2399d916f9 100644 --- a/tycho-surefire/org.eclipse.tycho.surefire.junit59withvintage/pom.xml +++ b/tycho-surefire/org.eclipse.tycho.surefire.junit59withvintage/pom.xml @@ -72,6 +72,21 @@ junit-vintage-engine ${junit-jupiter-version} + + org.junit.platform + junit-platform-suite-api + ${junit-platform-version} + + + org.junit.platform + junit-platform-suite-commons + ${junit-platform-version} + + + org.junit.platform + junit-platform-suite-engine + ${junit-platform-version} + org.opentest4j opentest4j diff --git a/tycho-surefire/org.eclipse.tycho.surefire.junit59withvintage/src/main/resources/META-INF/services/org.junit.platform.engine.TestEngine b/tycho-surefire/org.eclipse.tycho.surefire.junit59withvintage/src/main/resources/META-INF/services/org.junit.platform.engine.TestEngine index 4e28d5caa6..1e3bab1293 100644 --- a/tycho-surefire/org.eclipse.tycho.surefire.junit59withvintage/src/main/resources/META-INF/services/org.junit.platform.engine.TestEngine +++ b/tycho-surefire/org.eclipse.tycho.surefire.junit59withvintage/src/main/resources/META-INF/services/org.junit.platform.engine.TestEngine @@ -1,4 +1,5 @@ # Manual merge of META-INF/services/org.junit.platform.engine.TestEngine of both junit-vintage-engine and junit-jupiter-engine # otherwise only one of the two files would win when extracting dependencies org.junit.jupiter.engine.JupiterTestEngine -org.junit.vintage.engine.VintageTestEngine \ No newline at end of file +org.junit.vintage.engine.VintageTestEngine +org.junit.platform.suite.engine.SuiteTestEngine