From 74bd1ca02d037a69d94e350ea3016c3fd893eb31 Mon Sep 17 00:00:00 2001 From: Heiko Klare Date: Fri, 3 May 2024 10:59:22 +0200 Subject: [PATCH] Migrate test suites in org.eclipse.core.tests.runtime to JUnit 5 #903 Prepares the migration of the org.eclipse.core.tests.runtime project by migrating the test suites to JUnit 5. Contributes to https://github.com/eclipse-platform/eclipse.platform/issues/903 --- .../META-INF/MANIFEST.MF | 4 +- .../preferences/AllPreferenceTests.java | 23 +++++++---- .../runtime/AllInternalRuntimeTests.java | 11 +++-- .../core/tests/runtime/AllRuntimeTests.java | 10 +++-- .../tests/runtime/AutomatedRuntimeTests.java | 25 +++++------- .../core/tests/runtime/jobs/AllJobTests.java | 40 ++++++++++++++----- 6 files changed, 72 insertions(+), 41 deletions(-) diff --git a/runtime/tests/org.eclipse.core.tests.runtime/META-INF/MANIFEST.MF b/runtime/tests/org.eclipse.core.tests.runtime/META-INF/MANIFEST.MF index 3979a4639a8..256d1ff2ee2 100644 --- a/runtime/tests/org.eclipse.core.tests.runtime/META-INF/MANIFEST.MF +++ b/runtime/tests/org.eclipse.core.tests.runtime/META-INF/MANIFEST.MF @@ -14,7 +14,9 @@ Require-Bundle: org.junit, org.eclipse.test.performance;resolution:=optional, org.eclipse.core.runtime;bundle-version="3.29.0", org.eclipse.core.tests.harness;bundle-version="3.11.0" -Import-Package: org.assertj.core.api +Import-Package: org.assertj.core.api, + org.junit.jupiter.api, + org.junit.platform.suite.api Bundle-ActivationPolicy: lazy Bundle-RequiredExecutionEnvironment: JavaSE-17 Plugin-Class: org.eclipse.core.tests.runtime.RuntimeTestsPlugin diff --git a/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/internal/preferences/AllPreferenceTests.java b/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/internal/preferences/AllPreferenceTests.java index ae00fe2d2f4..d3615b35c3a 100644 --- a/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/internal/preferences/AllPreferenceTests.java +++ b/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/internal/preferences/AllPreferenceTests.java @@ -13,14 +13,23 @@ *******************************************************************************/ package org.eclipse.core.tests.internal.preferences; -import org.eclipse.core.tests.runtime.*; -import org.junit.runner.RunWith; -import org.junit.runners.Suite; +import org.eclipse.core.tests.runtime.PreferenceExportTest; +import org.eclipse.core.tests.runtime.PreferenceForwarderTest; +import org.eclipse.core.tests.runtime.PreferencesTest; +import org.junit.platform.suite.api.SelectClasses; +import org.junit.platform.suite.api.Suite; -@RunWith(Suite.class) -@Suite.SuiteClasses({ EclipsePreferencesTest.class, PreferencesServiceTest.class, IScopeContextTest.class, - TestBug388004.class, TestBug380859.class, PreferenceExportTest.class, PreferenceForwarderTest.class, - PreferencesTest.class }) +@Suite +@SelectClasses({ // + EclipsePreferencesTest.class, // + PreferencesServiceTest.class, // + IScopeContextTest.class, // + TestBug388004.class, // + TestBug380859.class, // + PreferenceExportTest.class, // + PreferenceForwarderTest.class, // + PreferencesTest.class, // +}) @SuppressWarnings("deprecation") public class AllPreferenceTests { } diff --git a/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/internal/runtime/AllInternalRuntimeTests.java b/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/internal/runtime/AllInternalRuntimeTests.java index c332ba49f56..765014a6b7a 100644 --- a/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/internal/runtime/AllInternalRuntimeTests.java +++ b/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/internal/runtime/AllInternalRuntimeTests.java @@ -13,10 +13,13 @@ *******************************************************************************/ package org.eclipse.core.tests.internal.runtime; -import org.junit.runner.RunWith; -import org.junit.runners.Suite; +import org.junit.platform.suite.api.SelectClasses; +import org.junit.platform.suite.api.Suite; -@RunWith(Suite.class) -@Suite.SuiteClasses({ LogSerializationTest.class, PlatformURLLocalTest.class, PlatformURLSessionTest.class }) +@Suite +@SelectClasses({ // + LogSerializationTest.class, // + PlatformURLLocalTest.class, // + PlatformURLSessionTest.class }) public class AllInternalRuntimeTests { } diff --git a/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/AllRuntimeTests.java b/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/AllRuntimeTests.java index 412acbc93f3..ebfd3983f63 100644 --- a/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/AllRuntimeTests.java +++ b/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/AllRuntimeTests.java @@ -13,11 +13,13 @@ *******************************************************************************/ package org.eclipse.core.tests.runtime; -import org.junit.runner.RunWith; -import org.junit.runners.Suite; +import org.junit.platform.suite.api.SelectClasses; +import org.junit.platform.suite.api.Suite; -@RunWith(Suite.class) -@Suite.SuiteClasses({ PlatformTest.class }) +@Suite +@SelectClasses({ // + PlatformTest.class, // +}) public class AllRuntimeTests { } diff --git a/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/AutomatedRuntimeTests.java b/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/AutomatedRuntimeTests.java index ec72a718c6d..17eec1c454d 100644 --- a/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/AutomatedRuntimeTests.java +++ b/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/AutomatedRuntimeTests.java @@ -16,27 +16,24 @@ import org.eclipse.core.tests.internal.preferences.AllPreferenceTests; import org.eclipse.core.tests.internal.runtime.AllInternalRuntimeTests; import org.eclipse.core.tests.runtime.jobs.AllJobTests; -import org.junit.runner.RunWith; -import org.junit.runners.Suite; +import org.junit.platform.suite.api.SelectClasses; +import org.junit.platform.suite.api.Suite; /** * Runs the sniff tests for the build. All tests listed here should be * automated. */ -@RunWith(Suite.class) -@Suite.SuiteClasses({ - AllInternalRuntimeTests.class, - - AllRuntimeTests.class, - - AllPreferenceTests.class, - - XmlProcessorFactoryTest.class, +@Suite +@SelectClasses({ // + AllInternalRuntimeTests.class, // + AllRuntimeTests.class, // + AllPreferenceTests.class, // + XmlProcessorFactoryTest.class, // /* - * Intentional the LAST TEST in the list to let JobEventTest.testNoTimeoutOccured() verify the other - * tests: + * Intentional the LAST TEST in the list to let + * JobEventTest.testNoTimeoutOccured() verify the other tests: */ - AllJobTests.class + AllJobTests.class, // }) public class AutomatedRuntimeTests { diff --git a/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/AllJobTests.java b/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/AllJobTests.java index c3611e9a48f..cea015eb0bd 100644 --- a/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/AllJobTests.java +++ b/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/AllJobTests.java @@ -14,25 +14,43 @@ *******************************************************************************/ package org.eclipse.core.tests.runtime.jobs; -import org.junit.runner.RunWith; -import org.junit.runners.Suite; +import org.junit.platform.suite.api.SelectClasses; +import org.junit.platform.suite.api.Suite; /** * Runs all job tests */ -@RunWith(Suite.class) -@Suite.SuiteClasses({ - YieldTest.class, IJobManagerTest.class, JobGroupTest.class, JobQueueTest.class, OrderedLockTest.class, - BeginEndRuleTest.class, JobTest.class, DeadlockDetectionTest.class, Bug_129551.class, Bug_211799.class, - Bug_307282.class, Bug_307391.class, MultiRuleTest.class, Bug_311756.class, Bug_311863.class, Bug_316839.class, - Bug_320329.class, Bug_478634.class, Bug_550738.class, Bug_574883.class, Bug_412138.class, - Bug_574883Join.class, GithubBug_193.class, - WorkerPoolTest.class, +@Suite +@SelectClasses({ // + YieldTest.class, // + IJobManagerTest.class, // + JobGroupTest.class, // + JobQueueTest.class, // + OrderedLockTest.class, // + BeginEndRuleTest.class, // + JobTest.class, // + DeadlockDetectionTest.class, // + Bug_129551.class, // + Bug_211799.class, // + Bug_307282.class, // + Bug_307391.class, // + MultiRuleTest.class, // + Bug_311756.class, // + Bug_311863.class, // + Bug_316839.class, // + Bug_320329.class, // + Bug_478634.class, // + Bug_550738.class, // + Bug_574883.class, // + Bug_412138.class, // + Bug_574883Join.class, // + GithubBug_193.class, // + WorkerPoolTest.class, // /* * Intentional the LAST TEST in the list to testNoTimeoutOccured() in the other * tests: */ - JobEventTest.class + JobEventTest.class, // }) public class AllJobTests { }