From f1b1a4361cf8087f4e67fe52be0a02e80bb06127 Mon Sep 17 00:00:00 2001 From: Simeon Andreev Date: Fri, 29 May 2026 11:32:33 +0300 Subject: [PATCH] Use TestExecutionListener to log test start and end in org.eclipse.ui.tests Add a JUnit Jupiter TestExecutionListener to org.eclipse.ui.tests, which logs test start and end events via UIPlugin. The listener is defined in org.eclipse.ui.tests.harness, so that it can be reused by other test bundles. Additionally, usage of TestRunLogUtil.LOG_TESTRUN rule is removed, since the new listener covers the rule functionality. Fixes: https://github.com/eclipse-platform/eclipse.platform.ui/issues/4032 --- .../META-INF/MANIFEST.MF | 4 +- .../tests/harness/util/LogTestListener.java | 40 +++++++++++++++++++ .../ui/tests/api/MultipleWindowsTest.java | 5 --- .../tests/filteredtree/PatternFilterTest.java | 5 --- .../markers/MarkerHelpRegistryReaderTest.java | 5 --- .../tests/markers/MarkerHelpRegistryTest.java | 5 --- .../ui/tests/markers/MarkerQueryTest.java | 5 --- .../ZoomAndPreferencesFontTest.java | 5 --- .../ui/tests/progress/JobInfoTest.java | 5 --- .../tests/progress/JobInfoTestOrdering.java | 5 --- .../progress/ProgressAnimationItemTest.java | 5 --- .../tests/releng/PluginActivationTests.java | 5 --- .../org.eclipse.ui.tests/META-INF/MANIFEST.MF | 1 + ...it.platform.launcher.TestExecutionListener | 1 + 14 files changed, 45 insertions(+), 51 deletions(-) create mode 100644 tests/org.eclipse.ui.tests.harness/src/org/eclipse/ui/tests/harness/util/LogTestListener.java create mode 100644 tests/org.eclipse.ui.tests/META-INF/services/org.junit.platform.launcher.TestExecutionListener diff --git a/tests/org.eclipse.ui.tests.harness/META-INF/MANIFEST.MF b/tests/org.eclipse.ui.tests.harness/META-INF/MANIFEST.MF index 2757a8e723e..8f60d9bc38f 100644 --- a/tests/org.eclipse.ui.tests.harness/META-INF/MANIFEST.MF +++ b/tests/org.eclipse.ui.tests.harness/META-INF/MANIFEST.MF @@ -10,7 +10,9 @@ Require-Bundle: org.eclipse.ui;bundle-version="3.208.0", org.eclipse.core.resources Bundle-ActivationPolicy: lazy Import-Package: org.junit.jupiter.api;version="[5.0.0,6.0.0)", - org.junit.jupiter.api.extension;version="[5.0.0,6.0.0)" + org.junit.jupiter.api.extension;version="[5.0.0,6.0.0)", + org.junit.platform.engine;version="[1.14.0,2.0.0)", + org.junit.platform.launcher;version="[1.14.0,2.0.0)" Export-Package: org.eclipse.ui.tests.harness, org.eclipse.ui.tests.harness.tests, org.eclipse.ui.tests.harness.util, diff --git a/tests/org.eclipse.ui.tests.harness/src/org/eclipse/ui/tests/harness/util/LogTestListener.java b/tests/org.eclipse.ui.tests.harness/src/org/eclipse/ui/tests/harness/util/LogTestListener.java new file mode 100644 index 00000000000..51b1fe96fcd --- /dev/null +++ b/tests/org.eclipse.ui.tests.harness/src/org/eclipse/ui/tests/harness/util/LogTestListener.java @@ -0,0 +1,40 @@ +/******************************************************************************* + * Copyright (c) 2026 Simeon Andreev 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: + * Simeon Andreev - initial API and implementation + *******************************************************************************/ +package org.eclipse.ui.tests.harness.util; + +import org.eclipse.core.runtime.Status; +import org.eclipse.ui.internal.UIPlugin; +import org.junit.platform.engine.TestExecutionResult; +import org.junit.platform.launcher.TestExecutionListener; +import org.junit.platform.launcher.TestIdentifier; + +/** + * Logs tests start and end. + */ +public class LogTestListener implements TestExecutionListener { + + @Override + public void executionStarted(TestIdentifier id) { + logInfo(id.getDisplayName() + " STARTING"); + } + + @Override + public void executionFinished(TestIdentifier id, TestExecutionResult result) { + logInfo(id.getDisplayName() + " DONE: " + result.getStatus()); + } + + private static void logInfo(String message) { + UIPlugin.getDefault().getLog().log(Status.info(message)); + } +} diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/MultipleWindowsTest.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/MultipleWindowsTest.java index c1f72c9e43e..302a0a5be8b 100644 --- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/MultipleWindowsTest.java +++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/MultipleWindowsTest.java @@ -19,20 +19,15 @@ import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.WorkbenchException; -import org.eclipse.ui.tests.harness.util.TestRunLogUtil; import org.junit.After; import org.junit.Before; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.TestWatcher; /** * A set of tests for multiple monitor situations that ensures interactions are * isolated to the respective window. */ public class MultipleWindowsTest { - @Rule - public TestWatcher LOG_TESTRUN = TestRunLogUtil.LOG_TESTRUN; IWorkbench wb; IWorkbenchWindow win1; diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/filteredtree/PatternFilterTest.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/filteredtree/PatternFilterTest.java index efef3e4676e..978739cb413 100644 --- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/filteredtree/PatternFilterTest.java +++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/filteredtree/PatternFilterTest.java @@ -23,15 +23,10 @@ import org.eclipse.jface.viewers.ISelection; import org.eclipse.swt.widgets.Control; import org.eclipse.ui.dialogs.PatternFilter; -import org.eclipse.ui.tests.harness.util.TestRunLogUtil; import org.junit.Before; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.TestWatcher; public class PatternFilterTest { - @Rule - public TestWatcher LOG_TESTRUN = TestRunLogUtil.LOG_TESTRUN; private class MockViewer extends ContentViewer { diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/markers/MarkerHelpRegistryReaderTest.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/markers/MarkerHelpRegistryReaderTest.java index 1f65b1222fd..17c09b10e7f 100644 --- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/markers/MarkerHelpRegistryReaderTest.java +++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/markers/MarkerHelpRegistryReaderTest.java @@ -22,17 +22,12 @@ import org.eclipse.ui.internal.ide.registry.MarkerHelpRegistry; import org.eclipse.ui.internal.ide.registry.MarkerHelpRegistryReader; import org.eclipse.ui.internal.ide.registry.MarkerQuery; -import org.eclipse.ui.tests.harness.util.TestRunLogUtil; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.TestWatcher; /** * The test class for {@link MarkerHelpRegistryReader}. */ public class MarkerHelpRegistryReaderTest { - @Rule - public TestWatcher LOG_TESTRUN = TestRunLogUtil.LOG_TESTRUN; /** * Tests if the matchChildren flag of the contributions to the markerHelp diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/markers/MarkerHelpRegistryTest.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/markers/MarkerHelpRegistryTest.java index 66b8ffb243d..04f62ae9295 100644 --- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/markers/MarkerHelpRegistryTest.java +++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/markers/MarkerHelpRegistryTest.java @@ -25,19 +25,14 @@ import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.ui.internal.ide.registry.MarkerHelpRegistry; import org.eclipse.ui.internal.ide.registry.MarkerHelpRegistryReader; -import org.eclipse.ui.tests.harness.util.TestRunLogUtil; import org.junit.After; import org.junit.Before; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.TestWatcher; /** * The test class for {@link MarkerHelpRegistry}. */ public class MarkerHelpRegistryTest { - @Rule - public TestWatcher LOG_TESTRUN = TestRunLogUtil.LOG_TESTRUN; static final String ATT_HELP_CONTEXT = "helpContext"; static final String ATT_HAS_HELP = "hasHelp"; diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/markers/MarkerQueryTest.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/markers/MarkerQueryTest.java index fe2b94b0ed4..4315d3ea4a9 100644 --- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/markers/MarkerQueryTest.java +++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/markers/MarkerQueryTest.java @@ -21,19 +21,14 @@ import org.eclipse.core.resources.IWorkspaceRoot; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.ui.internal.ide.registry.MarkerQuery; -import org.eclipse.ui.tests.harness.util.TestRunLogUtil; import org.junit.After; import org.junit.Before; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.TestWatcher; /** * The test class for {@link MarkerQuery}. */ public class MarkerQueryTest { - @Rule - public TestWatcher LOG_TESTRUN = TestRunLogUtil.LOG_TESTRUN; private IMarker marker; private IMarker child_marker; diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/preferences/ZoomAndPreferencesFontTest.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/preferences/ZoomAndPreferencesFontTest.java index 9865701b5f1..b74ef6ec55a 100644 --- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/preferences/ZoomAndPreferencesFontTest.java +++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/preferences/ZoomAndPreferencesFontTest.java @@ -35,23 +35,18 @@ import org.eclipse.ui.commands.ICommandService; import org.eclipse.ui.internal.themes.ColorsAndFontsPreferencePage; import org.eclipse.ui.part.FileEditorInput; -import org.eclipse.ui.tests.harness.util.TestRunLogUtil; import org.eclipse.ui.texteditor.AbstractTextEditor; import org.junit.After; import org.junit.Assert; import org.junit.Assume; import org.junit.Before; import org.junit.BeforeClass; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.TestWatcher; /** * @since 3.11 */ public class ZoomAndPreferencesFontTest { - @Rule - public TestWatcher LOG_TESTRUN = TestRunLogUtil.LOG_TESTRUN; private static IProject project; private static IFile file; diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/progress/JobInfoTest.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/progress/JobInfoTest.java index 697e6fc4b4a..e6b2b8f8c4a 100644 --- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/progress/JobInfoTest.java +++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/progress/JobInfoTest.java @@ -25,15 +25,10 @@ import org.eclipse.core.runtime.jobs.Job; import org.eclipse.ui.internal.progress.JobInfo; import org.eclipse.ui.internal.progress.JobSnapshot; -import org.eclipse.ui.tests.harness.util.TestRunLogUtil; import org.junit.Before; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.TestWatcher; public class JobInfoTest { - @Rule - public TestWatcher LOG_TESTRUN = TestRunLogUtil.LOG_TESTRUN; /** diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/progress/JobInfoTestOrdering.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/progress/JobInfoTestOrdering.java index 7bfe9a85f84..70496c8b3a2 100644 --- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/progress/JobInfoTestOrdering.java +++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/progress/JobInfoTestOrdering.java @@ -25,14 +25,9 @@ import org.eclipse.core.runtime.jobs.Job; import org.eclipse.ui.internal.progress.JobInfo; import org.eclipse.ui.internal.progress.JobSnapshot; -import org.eclipse.ui.tests.harness.util.TestRunLogUtil; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.TestWatcher; public class JobInfoTestOrdering { - @Rule - public TestWatcher LOG_TESTRUN = TestRunLogUtil.LOG_TESTRUN; /** * Test that checks when jobs sorted by their state, the running ones diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/progress/ProgressAnimationItemTest.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/progress/ProgressAnimationItemTest.java index a543fb3ad8e..2fc252c0850 100644 --- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/progress/ProgressAnimationItemTest.java +++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/progress/ProgressAnimationItemTest.java @@ -46,16 +46,11 @@ import org.eclipse.ui.internal.progress.ProgressManager; import org.eclipse.ui.internal.progress.ProgressRegion; import org.eclipse.ui.progress.IProgressConstants; -import org.eclipse.ui.tests.harness.util.TestRunLogUtil; import org.junit.After; import org.junit.Before; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.TestWatcher; public class ProgressAnimationItemTest { - @Rule - public TestWatcher LOG_TESTRUN = TestRunLogUtil.LOG_TESTRUN; private Shell shell; private ProgressAnimationItem animationItem; diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/releng/PluginActivationTests.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/releng/PluginActivationTests.java index 352d6e26f5e..e9ea22bb904 100644 --- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/releng/PluginActivationTests.java +++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/releng/PluginActivationTests.java @@ -24,12 +24,9 @@ import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.PartInitException; import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.tests.harness.util.TestRunLogUtil; import org.junit.Before; import org.junit.Ignore; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.TestWatcher; import org.osgi.framework.Bundle; import org.osgi.framework.FrameworkUtil; @@ -47,8 +44,6 @@ */ public class PluginActivationTests { - @Rule - public TestWatcher LOG_TESTRUN = TestRunLogUtil.LOG_TESTRUN; private static List NOT_ACTIVE_BUNDLES = List.of( "org.apache.xerces", diff --git a/tests/org.eclipse.ui.tests/META-INF/MANIFEST.MF b/tests/org.eclipse.ui.tests/META-INF/MANIFEST.MF index 59b92b8eb16..79e9af226dc 100644 --- a/tests/org.eclipse.ui.tests/META-INF/MANIFEST.MF +++ b/tests/org.eclipse.ui.tests/META-INF/MANIFEST.MF @@ -50,6 +50,7 @@ Import-Package: jakarta.annotation, org.junit.jupiter.api;version="[5.14.0,6.0.0)", org.junit.jupiter.api.extension;version="[5.14.0,6.0.0)", org.junit.jupiter.api.function;version="[5.14.0,6.0.0)", + org.junit.platform.launcher;version="[1.14.0,2.0.0)", org.junit.platform.suite.api;version="[1.14.0,2.0.0)", org.osgi.service.event Eclipse-AutoStart: true diff --git a/tests/org.eclipse.ui.tests/META-INF/services/org.junit.platform.launcher.TestExecutionListener b/tests/org.eclipse.ui.tests/META-INF/services/org.junit.platform.launcher.TestExecutionListener new file mode 100644 index 00000000000..67ccae5e97a --- /dev/null +++ b/tests/org.eclipse.ui.tests/META-INF/services/org.junit.platform.launcher.TestExecutionListener @@ -0,0 +1 @@ +org.eclipse.ui.tests.harness.util.LogTestListener \ No newline at end of file