Skip to content

Commit 66fb87c

Browse files
committed
Replace UITestCase with test rule in UI API tests
1 parent 577ef55 commit 66fb87c

33 files changed

+343
-396
lines changed

tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/IActionFilterTest.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,20 @@
1414
package org.eclipse.ui.tests.api;
1515

1616
import static org.eclipse.ui.tests.harness.util.UITestUtil.openTestWindow;
17+
import static org.junit.Assert.assertNotNull;
18+
import static org.junit.Assert.assertNull;
19+
import static org.junit.Assert.assertTrue;
1720

1821
import org.eclipse.jface.action.MenuManager;
1922
import org.eclipse.swt.SWT;
2023
import org.eclipse.swt.widgets.Event;
2124
import org.eclipse.ui.IWorkbenchPage;
2225
import org.eclipse.ui.IWorkbenchWindow;
2326
import org.eclipse.ui.tests.harness.util.ActionUtil;
24-
import org.eclipse.ui.tests.harness.util.UITestCase;
27+
import org.eclipse.ui.tests.harness.util.CloseTestWindowsRule;
28+
import org.junit.Before;
29+
import org.junit.Rule;
2530
import org.junit.Test;
26-
import org.junit.runner.RunWith;
27-
import org.junit.runners.JUnit4;
2831

2932
/**
3033
* Test the lifecycle of an action filter.
@@ -42,8 +45,10 @@
4245
* redTrueAction -> (name = red) (flag = true)
4346
* </pre>
4447
*/
45-
@RunWith(JUnit4.class)
46-
public class IActionFilterTest extends UITestCase {
48+
public class IActionFilterTest {
49+
50+
@Rule
51+
public final CloseTestWindowsRule closeTestWindows = new CloseTestWindowsRule();
4752

4853
protected IWorkbenchWindow fWindow;
4954

@@ -53,13 +58,8 @@ public class IActionFilterTest extends UITestCase {
5358

5459
protected String DYNAMIC_MENU_VIEW_ID = "org.eclipse.ui.tests.api.IActionFilterTest2";
5560

56-
public IActionFilterTest() {
57-
super(IActionFilterTest.class.getSimpleName());
58-
}
59-
60-
@Override
61-
protected void doSetUp() throws Exception {
62-
super.doSetUp();
61+
@Before
62+
public final void setUp() throws Exception {
6363
fWindow = openTestWindow();
6464
fPage = fWindow.getActivePage();
6565
}

tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/IAggregateWorkingSetTest.java

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
import static org.eclipse.ui.tests.harness.util.UITestUtil.processEvents;
1717
import static org.eclipse.ui.tests.harness.util.UITestUtil.waitForJobs;
1818
import static org.junit.Assert.assertArrayEquals;
19+
import static org.junit.Assert.assertEquals;
20+
import static org.junit.Assert.assertFalse;
21+
import static org.junit.Assert.assertNotNull;
22+
import static org.junit.Assert.assertNull;
1923

2024
import java.lang.reflect.Field;
2125
import java.lang.reflect.Method;
@@ -38,32 +42,31 @@
3842
import org.eclipse.ui.internal.AbstractWorkingSetManager;
3943
import org.eclipse.ui.internal.AggregateWorkingSet;
4044
import org.eclipse.ui.internal.IWorkbenchConstants;
41-
import org.eclipse.ui.tests.harness.util.UITestCase;
45+
import org.eclipse.ui.tests.harness.util.CloseTestWindowsRule;
46+
import org.junit.After;
47+
import org.junit.Before;
4248
import org.junit.Ignore;
49+
import org.junit.Rule;
4350
import org.junit.Test;
44-
import org.junit.runner.RunWith;
45-
import org.junit.runners.JUnit4;
4651

47-
@RunWith(JUnit4.class)
48-
public class IAggregateWorkingSetTest extends UITestCase {
52+
public class IAggregateWorkingSetTest {
4953

5054
static final String WORKING_SET_NAME = "testws";
5155
static final String AGGREGATE_WORKING_SET_NAME_ = "testaggregatews";
5256
static final String WSET_PAGE_ID="org.eclipse.ui.resourceWorkingSetPage";
57+
58+
@Rule
59+
public final CloseTestWindowsRule closeTestWindows = new CloseTestWindowsRule();
60+
5361
IWorkspace fWorkspace;
5462
IWorkbench fWorkbench;
5563

5664
IWorkingSet[] components;
5765
List<IWorkingSet> backup;
5866
IAggregateWorkingSet fWorkingSet;
5967

60-
public IAggregateWorkingSetTest() {
61-
super(IAggregateWorkingSetTest.class.getSimpleName());
62-
}
63-
64-
@Override
65-
protected void doSetUp() throws Exception {
66-
super.doSetUp();
68+
@Before
69+
public final void setUp() throws Exception {
6770
IWorkingSetManager workingSetManager = PlatformUI.getWorkbench().getWorkingSetManager();
6871
backup = Arrays.asList(workingSetManager.getAllWorkingSets());
6972

@@ -81,8 +84,9 @@ protected void doSetUp() throws Exception {
8184

8285
workingSetManager.addWorkingSet(fWorkingSet);
8386
}
84-
@Override
85-
protected void doTearDown() throws Exception {
87+
88+
@After
89+
public final void tearDown() throws Exception {
8690
IWorkingSetManager workingSetManager = fWorkbench.getWorkingSetManager();
8791
workingSetManager.removeWorkingSet(fWorkingSet);
8892
for (IWorkingSet component : components) {
@@ -95,7 +99,6 @@ protected void doTearDown() throws Exception {
9599
}
96100
}
97101
fWorkbench = null;
98-
super.doTearDown();
99102
}
100103

101104
@Test

tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/IDeprecatedWorkbenchPageTest.java

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@
1616
import static org.eclipse.ui.tests.harness.util.UITestUtil.getPageInput;
1717
import static org.eclipse.ui.tests.harness.util.UITestUtil.openTestPage;
1818
import static org.eclipse.ui.tests.harness.util.UITestUtil.openTestWindow;
19+
import static org.junit.Assert.assertEquals;
20+
import static org.junit.Assert.assertFalse;
21+
import static org.junit.Assert.assertNotNull;
22+
import static org.junit.Assert.assertNull;
23+
import static org.junit.Assert.assertTrue;
1924

2025
import org.eclipse.core.resources.IFile;
2126
import org.eclipse.core.resources.IMarker;
@@ -34,16 +39,19 @@
3439
import org.eclipse.ui.part.FileEditorInput;
3540
import org.eclipse.ui.tests.harness.util.ArrayUtil;
3641
import org.eclipse.ui.tests.harness.util.CallHistory;
42+
import org.eclipse.ui.tests.harness.util.CloseTestWindowsRule;
3743
import org.eclipse.ui.tests.harness.util.EmptyPerspective;
3844
import org.eclipse.ui.tests.harness.util.FileUtil;
39-
import org.eclipse.ui.tests.harness.util.UITestCase;
45+
import org.junit.After;
46+
import org.junit.Before;
4047
import org.junit.Ignore;
48+
import org.junit.Rule;
4149
import org.junit.Test;
42-
import org.junit.runner.RunWith;
43-
import org.junit.runners.JUnit4;
4450

45-
@RunWith(JUnit4.class)
46-
public class IDeprecatedWorkbenchPageTest extends UITestCase {
51+
public class IDeprecatedWorkbenchPageTest {
52+
53+
@Rule
54+
public final CloseTestWindowsRule closeTestWindows = new CloseTestWindowsRule();
4755

4856
private IWorkbench fWorkbench;
4957

@@ -53,21 +61,15 @@ public class IDeprecatedWorkbenchPageTest extends UITestCase {
5361

5462
private IProject proj;
5563

56-
public IDeprecatedWorkbenchPageTest() {
57-
super(IDeprecatedWorkbenchPageTest.class.getSimpleName());
58-
}
59-
60-
@Override
61-
protected void doSetUp() throws Exception {
62-
super.doSetUp();
64+
@Before
65+
public final void setUp() throws Exception {
6366
fWorkbench = PlatformUI.getWorkbench();
6467
fWin = openTestWindow();
6568
fActivePage = fWin.getActivePage();
6669
}
6770

68-
@Override
69-
protected void doTearDown() throws Exception {
70-
super.doTearDown();
71+
@After
72+
public final void tearDown() throws Exception {
7173
if (proj != null) {
7274
FileUtil.deleteProject(proj);
7375
proj = null;

tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/IEditorActionBarContributorTest.java

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,43 +14,39 @@
1414
package org.eclipse.ui.tests.api;
1515

1616
import static org.eclipse.ui.tests.harness.util.UITestUtil.openTestWindow;
17+
import static org.junit.Assert.assertEquals;
18+
import static org.junit.Assert.assertTrue;
1719

1820
import org.eclipse.core.resources.IFile;
1921
import org.eclipse.core.resources.IProject;
2022
import org.eclipse.ui.IWorkbenchPage;
2123
import org.eclipse.ui.IWorkbenchWindow;
2224
import org.eclipse.ui.part.FileEditorInput;
2325
import org.eclipse.ui.tests.harness.util.CallHistory;
26+
import org.eclipse.ui.tests.harness.util.CloseTestWindowsRule;
2427
import org.eclipse.ui.tests.harness.util.FileUtil;
25-
import org.eclipse.ui.tests.harness.util.UITestCase;
28+
import org.junit.Before;
29+
import org.junit.Rule;
2630
import org.junit.Test;
27-
import org.junit.runner.RunWith;
28-
import org.junit.runners.JUnit4;
2931

3032
/**
3133
* This is a test for IEditorPart. Since IEditorPart is an
3234
* interface this test verifies the IEditorPart lifecycle rather
3335
* than the implementation.
3436
*/
35-
@RunWith(JUnit4.class)
36-
public class IEditorActionBarContributorTest extends UITestCase {
37+
public class IEditorActionBarContributorTest {
38+
39+
@Rule
40+
public final CloseTestWindowsRule closeTestWindows = new CloseTestWindowsRule();
3741

3842
protected IWorkbenchWindow fWindow;
3943

4044
protected IWorkbenchPage fPage;
4145

4246
private final String EDITOR_ID = "org.eclipse.ui.tests.api.IEditorActionBarContributorTest";
4347

44-
/**
45-
* Constructor for IEditorPartTest
46-
*/
47-
public IEditorActionBarContributorTest() {
48-
super(IEditorActionBarContributorTest.class.getSimpleName());
49-
}
50-
51-
@Override
52-
protected void doSetUp() throws Exception {
53-
super.doSetUp();
48+
@Before
49+
public final void setUp() throws Exception {
5450
fWindow = openTestWindow();
5551
fPage = fWindow.getActivePage();
5652
}

tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/IEditorMatchingStrategyTest.java

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

1717
import static org.eclipse.ui.tests.harness.util.UITestUtil.openTestWindow;
18+
import static org.junit.Assert.assertEquals;
19+
import static org.junit.Assert.assertNotSame;
20+
import static org.junit.Assert.assertSame;
1821

1922
import org.eclipse.core.resources.IFile;
2023
import org.eclipse.core.resources.IProject;
2124
import org.eclipse.ui.IEditorPart;
2225
import org.eclipse.ui.IWorkbenchPage;
2326
import org.eclipse.ui.part.FileEditorInput;
27+
import org.eclipse.ui.tests.harness.util.CloseTestWindowsRule;
2428
import org.eclipse.ui.tests.harness.util.FileUtil;
25-
import org.eclipse.ui.tests.harness.util.UITestCase;
29+
import org.junit.Rule;
2630
import org.junit.Test;
27-
import org.junit.runner.RunWith;
28-
import org.junit.runners.JUnit4;
2931

3032
/**
3133
* Tests the <code>IEditorMatchingStrategyTest</code> API and behaviour.
3234
*
3335
* @since 3.1
3436
*/
35-
@RunWith(JUnit4.class)
36-
public class IEditorMatchingStrategyTest extends UITestCase {
37+
public class IEditorMatchingStrategyTest {
3738

3839
private static final String MATCHING_EDITOR_ID = "org.eclipse.ui.tests.api.MockMatchingEditorPart1";
3940

40-
public IEditorMatchingStrategyTest() {
41-
super(IEditorMatchingStrategyTest.class.getSimpleName());
42-
}
41+
@Rule
42+
public final CloseTestWindowsRule closeTestWindows = new CloseTestWindowsRule();
4343

4444
@Test
4545
public void testOpenMatchingEditor() throws Exception {

tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/IEditorPartTest.java

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414
package org.eclipse.ui.tests.api;
1515

1616
import static org.eclipse.ui.tests.harness.util.UITestUtil.processEvents;
17+
import static org.junit.Assert.assertEquals;
18+
import static org.junit.Assert.assertFalse;
19+
import static org.junit.Assert.assertNotNull;
20+
import static org.junit.Assert.assertTrue;
1721

1822
import java.util.ArrayList;
1923
import java.util.LinkedHashMap;
@@ -32,23 +36,13 @@
3236
import org.eclipse.ui.tests.harness.util.CallHistory;
3337
import org.eclipse.ui.tests.harness.util.FileUtil;
3438
import org.junit.Test;
35-
import org.junit.runner.RunWith;
36-
import org.junit.runners.JUnit4;
3739

3840
/**
3941
* This is a test for IEditorPart. Since IEditorPart is an interface this test
4042
* verifies the IEditorPart lifecycle rather than the implementation.
4143
*/
42-
@RunWith(JUnit4.class)
4344
public class IEditorPartTest extends IWorkbenchPartTest {
4445

45-
/**
46-
* Constructor for IEditorPartTest
47-
*/
48-
public IEditorPartTest() {
49-
super(IEditorPartTest.class.getSimpleName());
50-
}
51-
5246
/**
5347
* @see IWorkbenchPartTest#openPart(IWorkbenchPage)
5448
*/

tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/IEditorSiteTest.java

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

16+
import static org.junit.Assert.assertNull;
17+
1618
import org.eclipse.core.resources.IFile;
1719
import org.eclipse.core.resources.IProject;
1820
import org.eclipse.ui.IEditorPart;
@@ -22,19 +24,9 @@
2224
import org.eclipse.ui.ide.IDE;
2325
import org.eclipse.ui.tests.harness.util.FileUtil;
2426
import org.junit.Test;
25-
import org.junit.runner.RunWith;
26-
import org.junit.runners.JUnit4;
2727

28-
@RunWith(JUnit4.class)
2928
public class IEditorSiteTest extends IWorkbenchPartSiteTest {
3029

31-
/**
32-
* Constructor for IEditorSiteTest
33-
*/
34-
public IEditorSiteTest() {
35-
super(IEditorSiteTest.class.getSimpleName());
36-
}
37-
3830
/**
3931
* @see IWorkbenchPartSiteTest#getTestPartName()
4032
*/

tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/api/IPageLayoutTest.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,22 @@
1414
package org.eclipse.ui.tests.api;
1515

1616
import static org.eclipse.ui.tests.harness.util.UITestUtil.openTestWindow;
17+
import static org.junit.Assert.assertEquals;
1718

19+
import org.eclipse.ui.tests.harness.util.CloseTestWindowsRule;
1820
import org.eclipse.ui.tests.harness.util.EmptyPerspective;
19-
import org.eclipse.ui.tests.harness.util.UITestCase;
21+
import org.junit.Rule;
2022
import org.junit.Test;
21-
import org.junit.runner.RunWith;
22-
import org.junit.runners.JUnit4;
2323

2424
/**
2525
* Test cases for the <code>IPageLayout</code> API.
2626
*
2727
* @since 3.2
2828
*/
29-
@RunWith(JUnit4.class)
30-
public class IPageLayoutTest extends UITestCase {
29+
public class IPageLayoutTest {
3130

32-
public IPageLayoutTest() {
33-
super(IPageLayoutTest.class.getSimpleName());
34-
}
31+
@Rule
32+
public final CloseTestWindowsRule closeTestWindows = new CloseTestWindowsRule();
3533

3634
@Test
3735
public void testGetDescriptor() {

0 commit comments

Comments
 (0)