Skip to content

Commit 56cd0a1

Browse files
committed
Remove inheritance hierarchy from Ant UI performance tests
Ant UI tests use an inheritance hierarchy for sharing configuration and utility methods. This leads to duplications of performance test functionality and unnecessary classes for sharing utilities. This change removes the AbstractAntUIBuildPerformanceTest and AbstractAntPerformanceTest classes by reusing the PerformanceTestCaseJunit5 and integrating the remaining functionality into the single concrete performance test classes. In order to allow reuse of several inherited utility methods, they are moved to a dedicated AntUITestUtil class. In addition, the functionality for closing the welcome screen, which is embedded into the setup functionality of the common Ant UI test superclass, is extracted into a JUnit 5 extension to be used throughout all tests upon JUnit 5 migration.
1 parent 8df8bb6 commit 56cd0a1

File tree

20 files changed

+351
-360
lines changed

20 files changed

+351
-360
lines changed

ant/org.eclipse.ant.tests.ui/Ant Debug Tests/org/eclipse/ant/tests/ui/debug/AbstractAntDebugTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
*******************************************************************************/
1414
package org.eclipse.ant.tests.ui.debug;
1515

16+
import static org.eclipse.ant.tests.ui.testplugin.AntUITestUtil.getLaunchConfiguration;
17+
import static org.eclipse.ant.tests.ui.testplugin.AntUITestUtil.getLaunchManager;
1618
import static org.junit.Assert.assertNotNull;
1719
import static org.junit.Assert.assertTrue;
1820
import static org.junit.Assert.fail;
@@ -96,8 +98,7 @@ protected IBreakpointManager getBreakpointManager() {
9698
* the event waiter to use
9799
* @return Object the source of the event
98100
*/
99-
@Override
100-
protected Object launchAndWait(ILaunchConfiguration configuration, DebugEventWaiter waiter) throws CoreException {
101+
private Object launchAndWait(ILaunchConfiguration configuration, DebugEventWaiter waiter) throws CoreException {
101102
return launchAndWait(configuration, waiter, true);
102103
}
103104

ant/org.eclipse.ant.tests.ui/Ant Debug Tests/org/eclipse/ant/tests/ui/debug/BreakpointTests.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
*******************************************************************************/
1414
package org.eclipse.ant.tests.ui.debug;
1515

16+
import static org.eclipse.ant.tests.ui.testplugin.AntUITestUtil.getLaunchConfiguration;
1617
import static org.junit.Assert.assertEquals;
1718
import static org.junit.Assert.assertNotNull;
1819
import static org.junit.Assert.assertTrue;

ant/org.eclipse.ant.tests.ui/Ant Debug Tests/org/eclipse/ant/tests/ui/debug/PropertyTests.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
package org.eclipse.ant.tests.ui.debug;
1515

1616
import static org.assertj.core.api.Assertions.assertThat;
17+
import static org.eclipse.ant.tests.ui.testplugin.AntUITestUtil.getLaunchConfiguration;
1718
import static org.junit.Assert.assertEquals;
1819
import static org.junit.Assert.assertNotNull;
1920
import static org.junit.Assert.assertTrue;

ant/org.eclipse.ant.tests.ui/Ant Debug Tests/org/eclipse/ant/tests/ui/debug/SteppingTests.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
*******************************************************************************/
1414
package org.eclipse.ant.tests.ui.debug;
1515

16+
import static org.eclipse.ant.tests.ui.testplugin.AntUITestUtil.getLaunchConfiguration;
1617
import static org.junit.Assert.assertNotNull;
1718
import static org.junit.Assert.assertTrue;
1819

ant/org.eclipse.ant.tests.ui/Ant Editor Tests/org/eclipse/ant/tests/ui/editor/performance/OpenAntEditorTest.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,31 +14,33 @@
1414

1515
package org.eclipse.ant.tests.ui.editor.performance;
1616

17+
import static org.eclipse.ant.tests.ui.testplugin.AntUITestUtil.assertProject;
1718
import static org.junit.jupiter.api.Assertions.assertTrue;
1819

1920
import java.io.File;
2021

2122
import org.eclipse.ant.internal.ui.AntUIPlugin;
2223
import org.eclipse.ant.internal.ui.preferences.AntEditorPreferenceConstants;
23-
import org.eclipse.ant.tests.ui.performance.AbstractAntPerformanceTest;
2424
import org.eclipse.ant.tests.ui.testplugin.ProjectHelper;
2525
import org.eclipse.core.resources.IFile;
2626
import org.eclipse.core.resources.IProject;
2727
import org.eclipse.core.resources.ResourcesPlugin;
2828
import org.eclipse.jface.preference.IPreferenceStore;
2929
import org.eclipse.test.performance.Dimension;
30+
import org.eclipse.test.performance.PerformanceTestCaseJunit5;
3031
import org.eclipse.ui.PartInitException;
3132
import org.junit.jupiter.api.BeforeEach;
3233
import org.junit.jupiter.api.Test;
3334
import org.junit.jupiter.api.TestInfo;
3435

3536
@SuppressWarnings("restriction")
36-
public class OpenAntEditorTest extends AbstractAntPerformanceTest {
37+
public class OpenAntEditorTest extends PerformanceTestCaseJunit5 {
3738

3839
@BeforeEach
3940
@Override
4041
public void setUp(TestInfo testInfo) throws Exception {
4142
super.setUp(testInfo);
43+
assertProject();
4244
EditorTestHelper.runEventQueue();
4345
}
4446

ant/org.eclipse.ant.tests.ui/Ant Tests/org/eclipse/ant/tests/ui/AbstractAntUIBuildPerformanceTest.java

Lines changed: 0 additions & 87 deletions
This file was deleted.

ant/org.eclipse.ant.tests.ui/Ant Tests/org/eclipse/ant/tests/ui/AbstractAntUIBuildTest.java

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
package org.eclipse.ant.tests.ui;
1616

1717
import org.eclipse.ant.tests.ui.testplugin.AbstractAntUITest;
18-
import org.eclipse.core.runtime.CoreException;
19-
import org.eclipse.debug.core.ILaunchConfiguration;
2018
import org.eclipse.swt.widgets.Display;
2119
import org.eclipse.ui.console.IHyperlink;
2220
import org.junit.Rule;
@@ -26,16 +24,6 @@ public abstract class AbstractAntUIBuildTest extends AbstractAntUITest {
2624
@Rule
2725
public RunInSeparateThreadRule runInSeparateThread = new RunInSeparateThreadRule();
2826

29-
/**
30-
* Launches the launch configuration Waits for all of the lines to be appended
31-
* to the console.
32-
*
33-
* @param config the config to execute
34-
*/
35-
protected void launch(ILaunchConfiguration config) throws CoreException {
36-
launchAndTerminate(config, 20000);
37-
}
38-
3927
protected void activateLink(final IHyperlink link) {
4028
Display.getDefault().asyncExec(() -> link.linkActivated());
4129
}

ant/org.eclipse.ant.tests.ui/Ant Tests/org/eclipse/ant/tests/ui/AntUtilTests.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import org.eclipse.ant.internal.ui.model.IAntModel;
3434
import org.eclipse.ant.launching.IAntLaunchConstants;
3535
import org.eclipse.ant.tests.ui.testplugin.AbstractAntUITest;
36+
import org.eclipse.ant.tests.ui.testplugin.AntUITestUtil;
3637
import org.eclipse.core.externaltools.internal.IExternalToolConstants;
3738
import org.eclipse.core.runtime.CoreException;
3839
import org.eclipse.debug.core.ILaunchConfiguration;
@@ -275,7 +276,7 @@ private void assertTargets(AntTargetNode[] targets, String[] expectedTargetNames
275276
}
276277

277278
protected ILaunchConfiguration getLaunchConfiguration(String buildFileName, String arguments, Map<String, String> properties, String propertyFiles) throws CoreException {
278-
ILaunchConfiguration config = getLaunchConfiguration(buildFileName);
279+
ILaunchConfiguration config = AntUITestUtil.getLaunchConfiguration(buildFileName);
279280
assertNotNull("Could not locate launch configuration for " + buildFileName, config); //$NON-NLS-1$
280281
ILaunchConfigurationWorkingCopy copy = config.getWorkingCopy();
281282
if (arguments != null) {

ant/org.eclipse.ant.tests.ui/Ant Tests/org/eclipse/ant/tests/ui/BuildTests.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414

1515
package org.eclipse.ant.tests.ui;
1616

17+
import static org.eclipse.ant.tests.ui.testplugin.AntUITestUtil.getLaunchConfiguration;
18+
import static org.eclipse.ant.tests.ui.testplugin.AntUITestUtil.getProject;
19+
import static org.eclipse.ant.tests.ui.testplugin.AntUITestUtil.launchAndTerminate;
1720
import static org.junit.Assert.assertEquals;
1821
import static org.junit.Assert.assertFalse;
1922
import static org.junit.Assert.assertNotNull;

ant/org.eclipse.ant.tests.ui/Ant Tests/org/eclipse/ant/tests/ui/performance/AbstractAntPerformanceTest.java

Lines changed: 0 additions & 34 deletions
This file was deleted.

0 commit comments

Comments
 (0)