From fbf363d7a6f5d3c7a7d1f2caad79e96eb5a093c2 Mon Sep 17 00:00:00 2001 From: Heiko Klare Date: Wed, 10 Jan 2024 08:43:15 +0100 Subject: [PATCH] Provide tycho-surefire integration test for JUnit 5 suites Contributes to https://github.com/eclipse-tycho/tycho/issues/1454 --- .../bundle.test/META-INF/MANIFEST.MF | 8 ++++ .../bundle.test/build.properties | 4 ++ .../surefire.junit5suite/bundle.test/pom.xml | 37 +++++++++++++++++++ .../src/bundle/test/JUnit5Test.java | 28 ++++++++++++++ .../src/bundle/test/SuiteWithAllTests.java | 22 +++++++++++ .../tycho/test/surefire/JUnit5Test.java | 11 ++++++ 6 files changed, 110 insertions(+) create mode 100644 tycho-its/projects/surefire.junit5suite/bundle.test/META-INF/MANIFEST.MF create mode 100644 tycho-its/projects/surefire.junit5suite/bundle.test/build.properties create mode 100644 tycho-its/projects/surefire.junit5suite/bundle.test/pom.xml create mode 100644 tycho-its/projects/surefire.junit5suite/bundle.test/src/bundle/test/JUnit5Test.java create mode 100644 tycho-its/projects/surefire.junit5suite/bundle.test/src/bundle/test/SuiteWithAllTests.java diff --git a/tycho-its/projects/surefire.junit5suite/bundle.test/META-INF/MANIFEST.MF b/tycho-its/projects/surefire.junit5suite/bundle.test/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..3de8143678 --- /dev/null +++ b/tycho-its/projects/surefire.junit5suite/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.junit5suite +Bundle-Version: 1.0.0 +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 +Import-Package: org.junit.jupiter.api;version="5.0", + org.junit.platform.suite.api diff --git a/tycho-its/projects/surefire.junit5suite/bundle.test/build.properties b/tycho-its/projects/surefire.junit5suite/bundle.test/build.properties new file mode 100644 index 0000000000..34d2e4d2da --- /dev/null +++ b/tycho-its/projects/surefire.junit5suite/bundle.test/build.properties @@ -0,0 +1,4 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + . diff --git a/tycho-its/projects/surefire.junit5suite/bundle.test/pom.xml b/tycho-its/projects/surefire.junit5suite/bundle.test/pom.xml new file mode 100644 index 0000000000..fd8fd01a8b --- /dev/null +++ b/tycho-its/projects/surefire.junit5suite/bundle.test/pom.xml @@ -0,0 +1,37 @@ + + + 4.0.0 + org.eclipse.tycho.tycho-its.surefire-junit5 + bundle.test.junit5suite + 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.junit5suite/bundle.test/src/bundle/test/JUnit5Test.java b/tycho-its/projects/surefire.junit5suite/bundle.test/src/bundle/test/JUnit5Test.java new file mode 100644 index 0000000000..364ccf67a3 --- /dev/null +++ b/tycho-its/projects/surefire.junit5suite/bundle.test/src/bundle/test/JUnit5Test.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 JUnit5Test { + + @Test + @DisplayName("started from test suite") + void startedFromSuite() { + assertEquals(2, 1 + 1); + } + +} diff --git a/tycho-its/projects/surefire.junit5suite/bundle.test/src/bundle/test/SuiteWithAllTests.java b/tycho-its/projects/surefire.junit5suite/bundle.test/src/bundle/test/SuiteWithAllTests.java new file mode 100644 index 0000000000..dfdbae252f --- /dev/null +++ b/tycho-its/projects/surefire.junit5suite/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({ JUnit5Test.class })) +public class AllJUnit5Tests { + +} 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..a68d4aa82c 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,15 @@ public void testJUnit59Runner() throws Exception { // make sure test tagged as 'slow' was skipped assertNumberOfSuccessfulTests(projectBasedir, "bundle.test.JUnit59Test", 4); } + + @Test + public void testJUnit5Suite() throws Exception { + final Verifier verifier = getVerifier("/surefire.junit5suite/bundle.test"); + verifier.executeGoal("verify"); + verifier.verifyErrorFreeLog(); + final String projectBasedir = verifier.getBasedir(); + // make sure tests from suite were executed + assertNumberOfSuccessfulTests(projectBasedir, "bundle.test.SuiteWithAllTests", 1); + } + }