Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="3.29.0",
org.eclipse.pde.ui.tests;bundle-version="3.11.500",
org.eclipse.jdt.junit4.runtime;bundle-version="[1.3.0,2.0.0)",
org.eclipse.jdt.junit5.runtime;bundle-version="[1.1.0,2.0.0)",
org.eclipse.jdt.junit6.runtime;bundle-version="[1.0.0,2.0.0)",
org.eclipse.pde.junit.runtime;bundle-version="[3.8.0,4.0.0)"
Import-Package: org.assertj.core.api;version="3.14.0",
org.junit,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2019 Julian Honnen
* Copyright (c) 2019, 2025 Julian Honnen
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
Expand Down Expand Up @@ -77,7 +77,10 @@ public static void setupProjects() throws Exception {

@Parameters(name = "{0}")
public static Object[][] parameters() {
return new Object[][] { { "JUnit5", getJProject("verification.tests.junit5") },
return new Object[][] {
{ "JUnit6", getJProject("verification.tests.junit6") },
{ "JUnit6 Fragment", getJProject("verification.tests.junit6.fragment") },
{ "JUnit5", getJProject("verification.tests.junit5") },
{ "JUnit5 Fragment", getJProject("verification.tests.junit5.fragment") },
{ "JUnit4", getJProject("verification.tests.junit4") },
{ "JUnit4 Fragment", getJProject("verification.tests.junit4.fragment") },
Expand All @@ -101,25 +104,25 @@ public void executeType() throws Exception {
IType testClass = findType(project, "Test1");
ITestRunSession session = TestExecutionUtil.runTest(testClass);

assertThat(session.getChildren()).hasSize(1);
assertSuccessful(session);
assertThat(session.getChildren()).hasSize(1);
}

@Test
public void executePackage() throws Exception {
IPackageFragment testPackage = findType(project, "Test1").getPackageFragment();
ITestRunSession session = TestExecutionUtil.runTest(testPackage);

assertThat(session.getChildren()).hasSize(2);
assertSuccessful(session);
assertThat(session.getChildren()).hasSize(2);
}

@Test
public void executeProject() throws Exception {
ITestRunSession session = TestExecutionUtil.runTest(project);

assertThat(session.getChildren()).hasSize(2);
assertSuccessful(session);
assertThat(session.getChildren()).hasSize(2);
}

@Test
Expand All @@ -128,8 +131,8 @@ public void executeMethod() throws Exception {
Assume.assumeTrue(testMethod.exists());
ITestRunSession session = TestExecutionUtil.runTest(testMethod);

assertThat(session.getChildren()).hasSize(1);
assertSuccessful(session);
assertThat(session.getChildren()).hasSize(1);
}

static void assertSuccessful(ITestRunSession session) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2019 Julian Honnen
* Copyright (c) 2019, 2025 Julian Honnen
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
Expand All @@ -18,7 +18,7 @@
import org.junit.runners.Suite.SuiteClasses;

@RunWith(Suite.class)
@SuiteClasses({ JUnitExecutionTest.class, JUnit5SuiteExecutionTest.class })
@SuiteClasses({ JUnitExecutionTest.class, JUnitSuiteExecutionTest.class })
public class JUnitRuntimeTests {

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2021, 2022 Julian Honnen
* Copyright (c) 2021, 2022, 2025 Julian Honnen
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
Expand All @@ -15,6 +15,7 @@

import static org.assertj.core.api.Assertions.assertThat;
import static org.eclipse.pde.junit.runtime.tests.JUnitExecutionTest.findType;
import static org.eclipse.pde.junit.runtime.tests.JUnitExecutionTest.getJProject;

import java.util.StringJoiner;

Expand All @@ -30,36 +31,55 @@
import org.junit.ClassRule;
import org.junit.Test;
import org.junit.rules.TestRule;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameter;
import org.junit.runners.Parameterized.Parameters;

public class JUnit5SuiteExecutionTest {
@RunWith(Parameterized.class)
public class JUnitSuiteExecutionTest {

@ClassRule
public static final TestRule CLEAR_WORKSPACE = ProjectUtils.DELETE_ALL_WORKSPACE_PROJECTS_BEFORE_AND_AFTER;

private static IJavaProject project;

@BeforeClass
public static void setupProjects() throws Exception {
Assert.assertNotNull("junit-platform-suite-engine bundle missing", Platform.getBundle("junit-platform-suite-engine"));
Assert.assertNotNull("org.eclipse.jdt.junit5.runtime bundle missing", Platform.getBundle("org.eclipse.jdt.junit5.runtime"));
Assert.assertNotNull("org.eclipse.jdt.junit6.runtime bundle missing", Platform.getBundle("org.eclipse.jdt.junit6.runtime"));

JUnitExecutionTest.setupProjects();
project = JUnitExecutionTest.getJProject("verification.tests.junit5.suite");
}

@Parameters(name = "{0}")
public static Object[][] parameters() {
return new Object[][] {
{ "JUnit6", getJProject("verification.tests.junit6.suite"), "verification.tests.junit6" },
{ "JUnit5", getJProject("verification.tests.junit5.suite"), "verification.tests.junit5" },
};
}

@Parameter(0)
public String testCaseName; // Just for display
@Parameter(1)
public IJavaProject project;
@Parameter(2)
public String packageName;

@Test
public void executeSuite() throws Exception {
ITestRunSession session = TestExecutionUtil.runTest(findType(project, "TestSuite"));
JUnitExecutionTest.assertSuccessful(session);
Assert.assertEquals("""
verification.tests.junit5.suite.TestSuite
String expected = String.format("""
%1$s.suite.TestSuite
JUnit Jupiter
verification.tests.junit5.Test1
test1(verification.tests.junit5.Test1)
test2(verification.tests.junit5.Test1)
verification.tests.junit5.Test2
test(verification.tests.junit5.Test2)
""".strip(), toString(session).strip());
%1$s.Test1
test1(%1$s.Test1)
test2(%1$s.Test1)
%1$s.Test2
test(%1$s.Test2)
""", packageName);
Assert.assertEquals(expected.strip(), toString(session).strip());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src">
<attributes>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="bin"/>
</classpath>
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>verification.tests.junit6.fragment</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.8
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Fragment
Bundle-SymbolicName: verification.tests.junit6.fragment
Bundle-Version: 1.0.0.qualifier
Fragment-Host: verification.tests.junit5;bundle-version="1.0.0.qualifier"
Automatic-Module-Name: verification.tests.junit6.fragment
Bundle-RequiredExecutionEnvironment: JavaSE-17
Export-Package: verification.tests.junit6.fragment
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*******************************************************************************
* Copyright (c) 2025 Julian Honnen
*
* 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:
* Julian Honnen <julian.honnen@vector.com> - initial API and implementation
*******************************************************************************/
package verification.tests.junit6.fragment;

import org.junit.jupiter.api.Test;

class Test1 {

@Test
void test1() {

}

@Test
void test2() {

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*******************************************************************************
* Copyright (c) 2025 Julian Honnen
*
* 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:
* Julian Honnen <julian.honnen@vector.com> - initial API and implementation
*******************************************************************************/
package verification.tests.junit6.fragment;

import org.junit.jupiter.api.Test;

class Test2 {

@Test
void test() {

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src">
<attributes>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="bin"/>
</classpath>
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>verification.tests.junit6.suite</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.8
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Tests
Bundle-SymbolicName: verification.tests.junit6.suite
Bundle-Version: 1.0.0.qualifier
Automatic-Module-Name: verification.tests
Bundle-RequiredExecutionEnvironment: JavaSE-17
Require-Bundle: junit-platform-suite-api;bundle-version="[6.0.0,7.0.0)",
verification.tests.junit6
Export-Package: verification.tests.junit6.suite
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*******************************************************************************
* Copyright (c) 2025 Julian Honnen
*
* 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:
* Julian Honnen <julian.honnen@vector.com> - initial API and implementation
*******************************************************************************/
package verification.tests.junit6.suite;

import org.junit.platform.suite.api.SelectClasses;
import org.junit.platform.suite.api.Suite;

@Suite
@SelectClasses({ verification.tests.junit6.Test1.class, verification.tests.junit6.Test2.class })
class TestSuite {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src">
<attributes>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="bin"/>
</classpath>
Loading
Loading