Skip to content

Commit bdd6766

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

File tree

8 files changed

+57
-66
lines changed

8 files changed

+57
-66
lines changed

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

Lines changed: 4 additions & 12 deletions
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

Lines changed: 5 additions & 9 deletions
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,
@@ -41,7 +40,4 @@
4140
Test_org_eclipse_swt_graphics_ImageLoaderEvent.class,
4241
Test_org_eclipse_swt_graphics_Transform.class })
4342
public class AllGraphicsTests {
44-
public static void main(String[] args) {
45-
JUnitCore.main(AllGraphicsTests.class.getName());
46-
}
4743
}

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

Lines changed: 9 additions & 14 deletions
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 -
Lines changed: 5 additions & 9 deletions
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

Lines changed: 5 additions & 9 deletions
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
}

tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/performance/PerformanceTests.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,14 @@
1313
*******************************************************************************/
1414
package org.eclipse.swt.tests.junit.performance;
1515

16-
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 running SWT performance test cases.
2221
*/
23-
@RunWith(Suite.class)
24-
@Suite.SuiteClasses({
22+
@Suite
23+
@SelectClasses({
2524
Test_situational.class
2625
})
2726
public class PerformanceTests {

tests/org.eclipse.swt.tests/META-INF/MANIFEST.MF

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,14 @@ Bundle-Version: 3.107.800.qualifier
66
Bundle-Vendor: Eclipse.org
77
Export-Package: org.eclipse.swt.tests.junit,
88
org.eclipse.swt.tests.junit.performance
9-
Require-Bundle: org.junit;bundle-version="4.12.0",
9+
Require-Bundle: org.junit;bundle-version="4.13.2",
10+
junit-vintage-engine;bundle-version="5.12.0",
11+
junit-jupiter-engine;bundle-version="5.12.0",
12+
junit-jupiter-params;bundle-version="5.12.0",
13+
junit-jupiter-api;bundle-version="5.12.0",
14+
junit-platform-suite-api;bundle-version="1.12.0",
15+
junit-platform-suite-commons;bundle-version="1.12.0",
16+
junit-platform-suite-engine;bundle-version="1.12.0",
1017
org.eclipse.swt;bundle-version="3.120.0",
1118
org.eclipse.test;bundle-version="3.6.200",
1219
org.eclipse.test.performance;bundle-version="3.13.0"

tests/org.eclipse.swt.tests/pom.xml

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,23 @@
6060
</configuration>
6161
</execution>
6262
</executions>
63-
<dependencies>
64-
<dependency>
65-
<groupId>org.apache.maven.surefire</groupId>
66-
<artifactId>surefire-junit47</artifactId>
67-
<version>${surefire.version}</version>
68-
</dependency>
69-
</dependencies>
63+
<dependencies>
64+
<dependency>
65+
<groupId>org.apache.maven.surefire</groupId>
66+
<artifactId>surefire-junit-platform</artifactId>
67+
<version>${surefire.version}</version>
68+
</dependency>
69+
<dependency>
70+
<groupId>org.junit.vintage</groupId>
71+
<artifactId>junit-vintage-engine</artifactId>
72+
<version>5.12.0</version>
73+
</dependency>
74+
<dependency>
75+
<groupId>org.junit.platform</groupId>
76+
<artifactId>junit-platform-suite-engine</artifactId>
77+
<version>1.12.0</version>
78+
</dependency>
79+
</dependencies>
7080
</plugin>
7181
</plugins>
7282
</build>

0 commit comments

Comments
 (0)