Skip to content

Commit b3cd654

Browse files
committed
Migrate SWT suites to JUnit 5
First towards being able to move unit tests to JUnit 5.
1 parent 9440140 commit b3cd654

File tree

9 files changed

+104
-111
lines changed

9 files changed

+104
-111
lines changed

tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/AllBrowserTests.java

+4-12
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,12 @@
1414
package org.eclipse.swt.tests.junit;
1515

1616

17-
import org.eclipse.test.TracingSuite;
18-
import org.eclipse.test.TracingSuite.TracingOptions;
19-
import org.junit.runner.JUnitCore;
20-
import org.junit.runner.RunWith;
21-
import org.junit.runners.Suite;
17+
import org.junit.platform.suite.api.SelectClasses;
18+
import org.junit.platform.suite.api.Suite;
2219

23-
@RunWith(TracingSuite.class)
24-
@TracingOptions(stackDumpTimeoutSeconds = 60)
25-
@Suite.SuiteClasses({
20+
@Suite
21+
@SelectClasses({
2622
Test_org_eclipse_swt_browser_Browser.class,
2723
})
2824
public class AllBrowserTests {
29-
30-
public static void main(String[] args) {
31-
JUnitCore.main(AllBrowserTests.class.getName());
32-
}
3325
}

tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/AllGraphicsTests.java

+5-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2000, 2015 IBM Corporation and others.
2+
* Copyright (c) 2000, 2025 IBM Corporation and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -13,15 +13,14 @@
1313
*******************************************************************************/
1414
package org.eclipse.swt.tests.junit;
1515

16-
import org.junit.runner.JUnitCore;
17-
import org.junit.runner.RunWith;
18-
import org.junit.runners.Suite;
16+
import org.junit.platform.suite.api.SelectClasses;
17+
import org.junit.platform.suite.api.Suite;
1918

2019
/**
2120
* Suite for testing all of the graphics test cases.
2221
*/
23-
@RunWith(Suite.class)
24-
@Suite.SuiteClasses({ Test_org_eclipse_swt_graphics_Color.class,
22+
@Suite
23+
@SelectClasses({ Test_org_eclipse_swt_graphics_Color.class,
2524
Test_org_eclipse_swt_graphics_Cursor.class,
2625
Test_org_eclipse_swt_graphics_DeviceData.class,
2726
Test_org_eclipse_swt_graphics_Font.class,
@@ -42,7 +41,4 @@
4241
Test_org_eclipse_swt_graphics_ImageLoaderEvent.class,
4342
Test_org_eclipse_swt_graphics_Transform.class })
4443
public class AllGraphicsTests {
45-
public static void main(String[] args) {
46-
JUnitCore.main(AllGraphicsTests.class.getName());
47-
}
4844
}

tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/AllNonBrowserTests.java

+9-14
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2000, 2022 IBM Corporation and others.
2+
* Copyright (c) 2000, 2025 IBM Corporation and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -18,17 +18,16 @@
1818
import java.util.List;
1919

2020
import org.eclipse.swt.graphics.Resource;
21-
import org.junit.AfterClass;
22-
import org.junit.BeforeClass;
23-
import org.junit.runner.JUnitCore;
24-
import org.junit.runner.RunWith;
25-
import org.junit.runners.Suite;
21+
import org.junit.jupiter.api.AfterAll;
22+
import org.junit.jupiter.api.BeforeAll;
23+
import org.junit.platform.suite.api.SelectClasses;
24+
import org.junit.platform.suite.api.Suite;
2625

2726
/**
2827
* Suite for running most SWT test cases (all except for browser tests).
2928
*/
30-
@RunWith(Suite.class)
31-
@Suite.SuiteClasses({ Test_org_eclipse_swt_SWT.class, Test_org_eclipse_swt_SWTException.class,
29+
@Suite
30+
@SelectClasses({ Test_org_eclipse_swt_SWT.class, Test_org_eclipse_swt_SWTException.class,
3231
Test_org_eclipse_swt_SWTError.class, Test_org_eclipse_swt_widgets_Display.class, AllGraphicsTests.class,
3332
AllWidgetTests.class, Test_org_eclipse_swt_layout_GridData.class,
3433
Test_org_eclipse_swt_events_ControlEvent.class, Test_org_eclipse_swt_events_ModifyEvent.class,
@@ -50,7 +49,7 @@
5049
public class AllNonBrowserTests {
5150
private static List<Error> leakedResources;
5251

53-
@BeforeClass
52+
@BeforeAll
5453
public static void beforeClass() {
5554
// Set up ResourceTracked to detect any leaks
5655
leakedResources = new ArrayList<> ();
@@ -67,7 +66,7 @@ public static void beforeClass() {
6766
* through a test and not through @AfterClass, but this is a
6867
* suite class and not a test class, so it can't have tests.
6968
*/
70-
@AfterClass
69+
@AfterAll
7170
public static void afterClass() {
7271
// Run GC in order do detect any outstanding leaks
7372
System.gc ();
@@ -93,10 +92,6 @@ public static void afterClass() {
9392
}
9493
}
9594

96-
public static void main(String[] args) {
97-
JUnitCore.main(AllNonBrowserTests.class.getName());
98-
}
99-
10095
/*
10196
* The logical order to run the tests in is: - SWT, SWTError, SWTException -
10297
* Display - graphics classes - items and Caret, etc - widgets - dialogs -
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2000, 2015 IBM Corporation and others.
2+
* Copyright (c) 2000, 2025 IBM Corporation and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -14,21 +14,17 @@
1414
package org.eclipse.swt.tests.junit;
1515

1616

17-
import org.junit.runner.JUnitCore;
18-
import org.junit.runner.RunWith;
19-
import org.junit.runners.Suite;
17+
import org.junit.platform.suite.api.SelectClasses;
18+
import org.junit.platform.suite.api.Suite;
2019

2120
/**
2221
* Suite for running all SWT test cases.
2322
*/
24-
@RunWith(Suite.class)
25-
@Suite.SuiteClasses({
23+
@Suite
24+
@SelectClasses({
2625
AllNonBrowserTests.class,
2726
AllBrowserTests.class
2827
})
2928
public class AllTests {
3029

31-
public static void main(String[] args) {
32-
JUnitCore.main(AllTests.class.getName());
33-
}
3430
}

tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/AllWidgetTests.java

+5-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2000 2015 IBM Corporation and others.
2+
* Copyright (c) 2000, 2025 IBM Corporation and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -14,15 +14,14 @@
1414
*******************************************************************************/
1515
package org.eclipse.swt.tests.junit;
1616

17-
import org.junit.runner.JUnitCore;
18-
import org.junit.runner.RunWith;
19-
import org.junit.runners.Suite;
17+
import org.junit.platform.suite.api.SelectClasses;
18+
import org.junit.platform.suite.api.Suite;
2019

2120
/**
2221
* Suite for testing all of the widget test cases.
2322
*/
24-
@RunWith(Suite.class)
25-
@Suite.SuiteClasses({ Test_org_eclipse_swt_widgets_Shell.class,
23+
@Suite
24+
@SelectClasses({ Test_org_eclipse_swt_widgets_Shell.class,
2625
Test_org_eclipse_swt_widgets_ExpandItem.class, Test_org_eclipse_swt_widgets_MenuItem.class,
2726
Test_org_eclipse_swt_widgets_ToolItem.class, Test_org_eclipse_swt_widgets_TabItem.class,
2827
Test_org_eclipse_swt_widgets_TableItem.class, Test_org_eclipse_swt_widgets_TableColumn.class,
@@ -53,7 +52,4 @@
5352
Test_org_eclipse_swt_widgets_ScrolledComposite.class,
5453
Test_org_eclipse_swt_custom_BusyIndicator.class})
5554
public class AllWidgetTests {
56-
public static void main(String[] args) {
57-
JUnitCore.main(AllWidgetTests.class.getName());
58-
}
5955
}

0 commit comments

Comments
 (0)