Skip to content

Commit 3e4f480

Browse files
laeubieclipse-tycho-bot
authored andcommitted
Add JUnit 6 provider support
(cherry picked from commit a747a25)
1 parent 6fd083f commit 3e4f480

File tree

17 files changed

+718
-0
lines changed

17 files changed

+718
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Manifest-Version: 1.0
2+
Bundle-ManifestVersion: 2
3+
Bundle-Name: JUnit6 Test Plug-in
4+
Bundle-SymbolicName: bundle.test.junit6
5+
Bundle-Version: 1.0.0
6+
Bundle-RequiredExecutionEnvironment: JavaSE-17
7+
Import-Package: org.junit.jupiter.api;version="[6.0, 7.0)",
8+
org.junit.jupiter.params;version="[6.0, 7.0)",
9+
org.junit.jupiter.params.provider;version="[6.0, 7.0)"
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
source.. = src/
2+
bin.includes = META-INF/,\
3+
.
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project>
3+
<modelVersion>4.0.0</modelVersion>
4+
<groupId>org.eclipse.tycho.tycho-its.surefire-junit6</groupId>
5+
<artifactId>bundle.test.junit6</artifactId>
6+
<packaging>eclipse-test-plugin</packaging>
7+
<version>1.0.0</version>
8+
9+
<properties>
10+
<tycho-version>6.0.0-SNAPSHOT</tycho-version>
11+
</properties>
12+
13+
<repositories>
14+
<repository>
15+
<id>oxygen</id>
16+
<layout>p2</layout>
17+
<url>${target-platform}</url>
18+
</repository>
19+
</repositories>
20+
21+
<build>
22+
<plugins>
23+
<plugin>
24+
<groupId>org.eclipse.tycho</groupId>
25+
<artifactId>tycho-maven-plugin</artifactId>
26+
<version>${tycho-version}</version>
27+
<extensions>true</extensions>
28+
</plugin>
29+
<plugin>
30+
<groupId>org.eclipse.tycho</groupId>
31+
<artifactId>tycho-surefire-plugin</artifactId>
32+
<version>${tycho-version}</version>
33+
<configuration>
34+
<providerHint>junit6</providerHint>
35+
<excludedGroups>slow</excludedGroups>
36+
</configuration>
37+
</plugin>
38+
</plugins>
39+
</build>
40+
</project>
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2025 Eclipse Foundation and others.
3+
* This program and the accompanying materials
4+
* are made available under the terms of the Eclipse Public License 2.0
5+
* which accompanies this distribution, and is available at
6+
* https://www.eclipse.org/legal/epl-2.0/
7+
*
8+
* SPDX-License-Identifier: EPL-2.0
9+
*
10+
* Contributors:
11+
* Eclipse Foundation - initial API and implementation
12+
*******************************************************************************/
13+
package bundle.test;
14+
15+
import static org.junit.jupiter.api.Assertions.assertEquals;
16+
17+
import org.junit.jupiter.api.DisplayName;
18+
import org.junit.jupiter.api.RepeatedTest;
19+
import org.junit.jupiter.api.Tag;
20+
import org.junit.jupiter.api.Test;
21+
import org.junit.jupiter.api.TestInfo;
22+
import org.junit.jupiter.params.ParameterizedTest;
23+
import org.junit.jupiter.params.provider.ValueSource;
24+
25+
class JUnit6Test {
26+
27+
@Test
28+
@DisplayName("My 1st JUnit 6 test!")
29+
void myFirstJUnit6Test(TestInfo testInfo) {
30+
assertEquals(2, 1+1, "1 + 1 should equal 2");
31+
assertEquals("My 1st JUnit 6 test!", testInfo.getDisplayName(), () -> "TestInfo is injected correctly");
32+
}
33+
34+
@Test
35+
@Tag("slow")
36+
void slowJUnit6Test() {
37+
assertEquals(2, 1+1, "1 + 1 should equal 2");
38+
}
39+
40+
@ParameterizedTest
41+
@ValueSource(strings = { "one", "two" })
42+
void parameterizedJUnit6Test(String input) {
43+
assertEquals(3, input.length(), "input length should be 3");
44+
}
45+
46+
@RepeatedTest(3)
47+
void repeatedJUnit6Test() {
48+
assertEquals(2, 1+1, "1 + 1 should equal 2");
49+
}
50+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2025 Eclipse Foundation and others.
3+
* This program and the accompanying materials
4+
* are made available under the terms of the Eclipse Public License 2.0
5+
* which accompanies this distribution, and is available at
6+
* https://www.eclipse.org/legal/epl-2.0/
7+
*
8+
* SPDX-License-Identifier: EPL-2.0
9+
*
10+
* Contributors:
11+
* Eclipse Foundation - initial API and implementation
12+
*******************************************************************************/
13+
package org.eclipse.tycho.test.surefire;
14+
15+
import static org.eclipse.tycho.test.util.SurefireUtil.assertNumberOfSuccessfulTests;
16+
import static org.eclipse.tycho.test.util.SurefireUtil.assertTestMethodWasSuccessfullyExecuted;
17+
18+
import org.apache.maven.it.Verifier;
19+
import org.eclipse.tycho.test.AbstractTychoIntegrationTest;
20+
import org.junit.jupiter.api.Test;
21+
22+
public class JUnit6Test extends AbstractTychoIntegrationTest {
23+
24+
/**
25+
* Tests that the JUnit 6 provider can be explicitly selected using
26+
* providerHint. Since JUnit 6 doesn't exist yet, this test uses JUnit 5.x
27+
* libraries with the junit6 provider hint to verify that the provider
28+
* infrastructure is in place.
29+
*
30+
* @throws Exception
31+
*/
32+
@Test
33+
public void testJUnit6ProviderHint() throws Exception {
34+
final Verifier verifier = getVerifier("/tycho-surefire-plugin/junit6/basic", false);
35+
verifier.addCliOption("-Dtarget-platform=https:///download.eclipse.org/releases/2025-12");
36+
verifier.executeGoal("verify");
37+
verifier.verifyErrorFreeLog();
38+
final String projectBasedir = verifier.getBasedir();
39+
assertTestMethodWasSuccessfullyExecuted(projectBasedir, "bundle.test.JUnit6Test", "My 1st JUnit 6 test!");
40+
assertTestMethodWasSuccessfullyExecuted(projectBasedir, "bundle.test.JUnit6Test",
41+
"parameterizedJUnit6Test(String)[1] \"one\"");
42+
assertTestMethodWasSuccessfullyExecuted(projectBasedir, "bundle.test.JUnit6Test",
43+
"parameterizedJUnit6Test(String)[2] \"two\"");
44+
assertTestMethodWasSuccessfullyExecuted(projectBasedir, "bundle.test.JUnit6Test",
45+
"repeatedJUnit6Test() repetition 1 of 3");
46+
assertTestMethodWasSuccessfullyExecuted(projectBasedir, "bundle.test.JUnit6Test",
47+
"repeatedJUnit6Test() repetition 2 of 3");
48+
assertTestMethodWasSuccessfullyExecuted(projectBasedir, "bundle.test.JUnit6Test",
49+
"repeatedJUnit6Test() repetition 3 of 3");
50+
// make sure test tagged as 'slow' was skipped
51+
assertNumberOfSuccessfulTests(projectBasedir, "bundle.test.JUnit6Test", 6);
52+
}
53+
54+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# override global rule
2+
!/.settings/
3+
4+
# only include specified files
5+
/.settings/*
6+
!/.settings/org.eclipse.jdt.core.prefs
7+
!/.settings/org.eclipse.jdt.ui.prefs
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# We only import some of the junit packages here to create a requirement on them and to allow
2+
# to load them if the test bundle itself does not import them already.
3+
# Apart from that the content in this bundle is only used to bootstrap
4+
# surefire and we include all we need for that as it does not comply with OSGi rules.
5+
Import-Package: \
6+
org.junit.platform.launcher, \
7+
org.junit.jupiter.api, \
8+
org.junit.jupiter.engine, \
9+
org.junit.platform.suite.api, \
10+
org.junit.platform.suite.engine;status=INTERNAL, \
11+
java.*
12+
Fragment-Host: org.eclipse.tycho.surefire.osgibooter
13+
# The JUnit Runner is still compatible with Java 1.8, as all included upstream dependencies are.
14+
# (This is checked in the tycho-surefire-plugin's pom.xml. See execution 'enforce-runtime-jdk-compatibility'.)
15+
Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.8))"
16+
-removeheaders: Tool, Bnd-*, Created-By, Private-Package
17+
-fixupmessages "Classes found in the wrong directory"; is:=warning
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
- Copyright (c) 2025 Eclipse Foundation and others.
4+
- All rights reserved. This program and the accompanying materials
5+
- are made available under the terms of the Eclipse Public License v1.0
6+
- which accompanies this distribution, and is available at
7+
- https://www.eclipse.org/legal/epl-v10.html
8+
-
9+
- Contributors:
10+
- Eclipse Foundation - initial API and implementation
11+
-->
12+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
13+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/maven-v4_0_0.xsd">
14+
<modelVersion>4.0.0</modelVersion>
15+
<parent>
16+
<groupId>org.eclipse.tycho</groupId>
17+
<artifactId>tycho-surefire</artifactId>
18+
<version>5.0.2-SNAPSHOT</version>
19+
</parent>
20+
<artifactId>org.eclipse.tycho.surefire.junit6</artifactId>
21+
<packaging>jar</packaging>
22+
<name>Tycho Surefire OSGi JUnit 6.x Runner</name>
23+
<build>
24+
<plugins>
25+
<plugin>
26+
<groupId>biz.aQute.bnd</groupId>
27+
<artifactId>bnd-maven-plugin</artifactId>
28+
</plugin>
29+
<plugin>
30+
<groupId>org.apache.maven.plugins</groupId>
31+
<artifactId>maven-dependency-plugin</artifactId>
32+
<configuration>
33+
<excludes>META-INF/**</excludes>
34+
<artifactItems>
35+
<artifactItem>
36+
<groupId>org.apache.maven.surefire</groupId>
37+
<artifactId>surefire-junit-platform</artifactId>
38+
<version>${surefire-version}</version>
39+
</artifactItem>
40+
</artifactItems>
41+
</configuration>
42+
</plugin>
43+
</plugins>
44+
</build>
45+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
org.junit.jupiter.engine.JupiterTestEngine
2+
org.junit.platform.suite.engine.SuiteTestEngine
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
2+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3+
<html xmlns="http://www.w3.org/1999/xhtml">
4+
<head>
5+
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
6+
<title>About</title>
7+
</head>
8+
<body lang="EN-US">
9+
<h2>About This Content</h2>
10+
11+
<p>June 25, 2012</p>
12+
<h3>License</h3>
13+
14+
<p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;). Unless otherwise
15+
indicated below, the Content is provided to you under the terms and conditions of the
16+
Eclipse Public License Version 1.0 (&quot;EPL&quot;). A copy of the EPL is available
17+
at <a href="https://www.eclipse.org/legal/epl-v10.html">https://www.eclipse.org/legal/epl-v10.html</a>.
18+
For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
19+
20+
<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
21+
being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may
22+
apply to your use of any object code in the Content. Check the Redistributor's license that was
23+
provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
24+
indicated below, the terms and conditions of the EPL still apply to any source code in the Content
25+
and such source code may be obtained at <a href="https://www.eclipse.org">https://www.eclipse.org</a>.</p>
26+
27+
<h3>Third Party Content</h3>
28+
<p>The Content includes items that have been sourced from third parties as set out below. If you
29+
did not receive this Content directly from the Eclipse Foundation, the following is provided
30+
for informational purposes only, and you should look to the Redistributor&rsquo;s license for
31+
terms and conditions of use.</p>
32+
33+
<h4>JUnit Platform Surefire Provider ${surefire-version}</h4>
34+
<p>The plug-in includes JUnit Platform Surefire Provider ${surefire-version} developed by the Apache Software Foundation. Therefore:</p>
35+
36+
<blockquote>
37+
This product includes software developed by the Apache Software Foundation (<a href="http://www.apache.org/">http://www.apache.org/</a>).
38+
</blockquote>
39+
40+
<p>JUnit Platform Surefire Provider ${surefire-version} is:</p>
41+
42+
<blockquote>Copyright (c) 2004-2011 The Apache Software Foundation. All rights reserved.</blockquote>
43+
44+
<p>Your use of the JUnit Platform Surefire Provider code is subject to the terms and conditions of the Apache Software License 2.0. A copy of the license is contained
45+
in the file <a href="about_files/LICENSE">LICENSE</a> and is also available at <a href="http://www.apache.org/licenses/LICENSE-2.0.html">http://www.apache.org/licenses/LICENSE-2.0.html</a>.
46+
47+
<p>The Apache attribution <a href="about_files/NOTICE">NOTICE</a> file is included with the Content in accordance with 4d of the Apache License, Version 2.0.</p>
48+
49+
<p>Examples and documentation as well as updated source code for SureFire JUnitCore Runner is available at <a href="http://maven.apache.org/surefire/">http://maven.apache.org/surefire/</a>.</p>
50+
51+
</body>
52+
</html>

0 commit comments

Comments
 (0)