From 6893a47c6351fae369afbf88efce2e7aba1e019f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Kubitz?= Date: Wed, 9 Oct 2024 16:32:27 +0200 Subject: [PATCH] [ui.tests] log a TestException instead of RuntimeException Nightly org.eclipse.ui.tests.UiTestSuite.txt contains intentional RuntimeException that are hard to distinguish from unintentional exceptions. --- .../ui/tests/api/BadElementFactory.java | 4 +-- .../ui/tests/api/IWorkingSetManagerTest.java | 2 +- .../eclipse/ui/tests/api/TestException.java | 25 +++++++++++++++++++ 3 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/TestException.java diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/BadElementFactory.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/BadElementFactory.java index 48d342c3574..d6db6832cd3 100644 --- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/BadElementFactory.java +++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/BadElementFactory.java @@ -72,7 +72,7 @@ public String getFactoryId() { public void saveState(IMemento memento) { if (shouldSaveFail) { saveAttemptedWhileShouldFail = true; - throw new RuntimeException(); + throw new TestException(); } } @@ -83,7 +83,7 @@ public void saveState(IMemento memento) { public IAdaptable createElement(IMemento memento) { if (shouldFailOnCreateElement) { elementCreationAttemptedWhileShouldFail = true; - throw new RuntimeException(); + throw new TestException(); } return new BadElementInstance(); } diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/IWorkingSetManagerTest.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/IWorkingSetManagerTest.java index e251eaf394a..230472282f1 100644 --- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/IWorkingSetManagerTest.java +++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/IWorkingSetManagerTest.java @@ -419,7 +419,7 @@ public void testListenerSafety() throws Throwable { final boolean[] result = new boolean[1]; // add a bogus listener that dies unexpectedly IPropertyChangeListener badListener = event -> { - throw new RuntimeException(); + throw new TestException(); }; IPropertyChangeListener goodListener = event -> result[0] = true; diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/TestException.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/TestException.java new file mode 100644 index 00000000000..f73593f7254 --- /dev/null +++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/TestException.java @@ -0,0 +1,25 @@ +/******************************************************************************* + * Copyright (c) 2024 Joerg Kubitz 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: + * Joerg Kubitz - initial API and implementation + ******************************************************************************/ + +package org.eclipse.ui.tests.api; + +public class TestException extends RuntimeException { + + private static final long serialVersionUID = 1L; + + public TestException() { + super("Intentional TestException. Ignore me in the logfile."); + } + +}