Skip to content

Commit dfdd99b

Browse files
committed
Convert some tests to JUnit 5
1 parent fd9f122 commit dfdd99b

13 files changed

+224
-283
lines changed

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

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@
1414
*******************************************************************************/
1515
package org.eclipse.swt.tests.junit;
1616

17-
import static org.junit.Assert.assertEquals;
18-
import static org.junit.Assert.assertTrue;
17+
import static org.junit.jupiter.api.Assertions.assertEquals;
18+
import static org.junit.jupiter.api.Assertions.assertTrue;
1919

2020
import java.io.ByteArrayOutputStream;
2121
import java.io.PrintStream;
2222

2323
import org.eclipse.swt.SWT;
2424
import org.eclipse.swt.SWTError;
25-
import org.junit.Test;
25+
import org.junit.jupiter.api.Test;
2626

2727
/**
2828
* Automated Test Suite for class org.eclipse.swt.SWTError
@@ -33,39 +33,30 @@ public class Test_org_eclipse_swt_SWTError {
3333

3434
@Test
3535
public void test_Constructor() {
36-
assertEquals (
37-
"did not fill in code properly",
38-
SWT.ERROR_UNSPECIFIED, new SWTError().code);
36+
assertEquals(SWT.ERROR_UNSPECIFIED, new SWTError().code, "did not fill in code properly");
3937
}
4038

4139
@Test
4240
public void test_ConstructorI() {
43-
assertEquals(
44-
"did not fill in code properly",SWT.ERROR_CANNOT_BE_ZERO,
45-
new SWTError(SWT.ERROR_CANNOT_BE_ZERO).code );
41+
assertEquals(SWT.ERROR_CANNOT_BE_ZERO, new SWTError(SWT.ERROR_CANNOT_BE_ZERO).code,
42+
"did not fill in code properly");
4643
}
4744

4845
@Test
4946
public void test_ConstructorILjava_lang_String() {
50-
assertEquals (
51-
"did not fill in code properly",SWT.ERROR_CANNOT_BE_ZERO,
52-
new SWTError(SWT.ERROR_CANNOT_BE_ZERO, "An uninteresting message").code
53-
);
47+
assertEquals(SWT.ERROR_CANNOT_BE_ZERO, new SWTError(SWT.ERROR_CANNOT_BE_ZERO, "An uninteresting message").code,
48+
"did not fill in code properly");
5449
}
5550

5651
@Test
5752
public void test_ConstructorLjava_lang_String() {
58-
assertEquals(
59-
"did not fill in code properly",SWT.ERROR_UNSPECIFIED,
60-
new SWTError("An uninteresting message").code);
53+
assertEquals(SWT.ERROR_UNSPECIFIED, new SWTError("An uninteresting message").code, "did not fill in code properly");
6154
}
6255

6356
@Test
6457
public void test_getMessage() {
65-
assertTrue (
66-
"did not include creation string in result",
67-
new SWTError(SWT.ERROR_CANNOT_BE_ZERO, "An interesting message").getMessage()
68-
.contains("An interesting message"));
58+
assertTrue(new SWTError(SWT.ERROR_CANNOT_BE_ZERO, "An interesting message").getMessage()
59+
.contains("An interesting message"), "did not include creation string in result");
6960
}
7061

7162
@Test

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

Lines changed: 12 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@
1414
*******************************************************************************/
1515
package org.eclipse.swt.tests.junit;
1616

17-
18-
import static org.junit.Assert.assertTrue;
17+
import static org.junit.jupiter.api.Assertions.assertEquals;
18+
import static org.junit.jupiter.api.Assertions.assertTrue;
1919

2020
import java.io.ByteArrayOutputStream;
2121
import java.io.PrintStream;
2222

2323
import org.eclipse.swt.SWT;
2424
import org.eclipse.swt.SWTException;
25-
import org.junit.Test;
25+
import org.junit.jupiter.api.Test;
2626

2727
/**
2828
* Automated Test Suite for class org.eclipse.swt.SWTException
@@ -33,53 +33,36 @@ public class Test_org_eclipse_swt_SWTException {
3333

3434
@Test
3535
public void test_Constructor() {
36-
assertTrue (
37-
"did not fill in code properly",
38-
new SWTException().code == SWT.ERROR_UNSPECIFIED);
36+
assertEquals(SWT.ERROR_UNSPECIFIED, new SWTException().code, "did not fill in code properly");
3937
}
4038

4139
@Test
4240
public void test_ConstructorI() {
43-
assertTrue (
44-
"did not fill in code properly",
45-
new SWTException(SWT.ERROR_CANNOT_BE_ZERO).code == SWT.ERROR_CANNOT_BE_ZERO);
41+
assertEquals(SWT.ERROR_CANNOT_BE_ZERO, new SWTException(SWT.ERROR_CANNOT_BE_ZERO).code,
42+
"did not fill in code properly");
4643
}
4744

4845
@Test
4946
public void test_ConstructorILjava_lang_String() {
50-
assertTrue (
51-
"did not fill in code properly",
52-
new SWTException(SWT.ERROR_CANNOT_BE_ZERO, "An uninteresting message").code
53-
== SWT.ERROR_CANNOT_BE_ZERO);
47+
assertEquals(SWT.ERROR_CANNOT_BE_ZERO, new SWTException(SWT.ERROR_CANNOT_BE_ZERO, "An uninteresting message").code,
48+
"did not fill in code properly");
5449
}
5550

5651
@Test
5752
public void test_ConstructorLjava_lang_String() {
58-
assertTrue (
59-
"did not fill in code properly",
60-
new SWTException("An uninteresting message").code == SWT.ERROR_UNSPECIFIED);
53+
assertEquals(SWT.ERROR_UNSPECIFIED, new SWTException("An uninteresting message").code,
54+
"did not fill in code properly");
6155
}
6256

6357
@Test
6458
public void test_getMessage() {
65-
assertTrue (
66-
"did not include creation string in result",
67-
new SWTException(SWT.ERROR_CANNOT_BE_ZERO, "An interesting message").getMessage()
68-
.contains("An interesting message"));
59+
assertTrue(new SWTException(SWT.ERROR_CANNOT_BE_ZERO, "An interesting message").getMessage()
60+
.contains("An interesting message"), "did not include creation string in result");
6961
}
7062

7163
@Test
7264
public void test_printStackTrace() {
7365

74-
// WARNING: this test is not CLDC safe, because it requires java.io.PrintStream
75-
76-
try {
77-
Class.forName("java.io.PrintStream");
78-
} catch (ClassNotFoundException e) {
79-
// ignore test if running on CLDC
80-
return;
81-
}
82-
8366
// test default SWTException
8467

8568
ByteArrayOutputStream out = new ByteArrayOutputStream();

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
*******************************************************************************/
1515
package org.eclipse.swt.tests.junit;
1616

17-
import static org.junit.Assert.assertEquals;
18-
import static org.junit.Assert.assertFalse;
19-
import static org.junit.Assert.assertTrue;
17+
import static org.junit.jupiter.api.Assertions.assertEquals;
18+
import static org.junit.jupiter.api.Assertions.assertFalse;
19+
import static org.junit.jupiter.api.Assertions.assertTrue;
2020

2121
import org.eclipse.swt.accessibility.Accessible;
2222
import org.eclipse.swt.accessibility.AccessibleControlEvent;
@@ -26,9 +26,9 @@
2626
import org.eclipse.swt.accessibility.AccessibleTextEvent;
2727
import org.eclipse.swt.accessibility.AccessibleTextListener;
2828
import org.eclipse.swt.widgets.Shell;
29-
import org.junit.After;
30-
import org.junit.Before;
31-
import org.junit.Test;
29+
import org.junit.jupiter.api.AfterEach;
30+
import org.junit.jupiter.api.BeforeEach;
31+
import org.junit.jupiter.api.Test;
3232

3333
/**
3434
* Automated Test Suite for class org.eclipse.swt.accessibility.Accessible
@@ -37,13 +37,13 @@
3737
*/
3838
public class Test_org_eclipse_swt_accessibility_Accessible {
3939

40-
@Before
40+
@BeforeEach
4141
public void setUp() {
4242
shell = new Shell();
4343
accessible = shell.getAccessible();
4444
}
4545

46-
@After
46+
@AfterEach
4747
public void tearDown() {
4848
assertFalse(shell.isDisposed());
4949
shell.dispose();

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

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@
1414
*******************************************************************************/
1515
package org.eclipse.swt.tests.junit;
1616

17-
import static org.junit.Assert.assertNotNull;
18-
import static org.junit.Assert.assertTrue;
17+
import static org.junit.jupiter.api.Assertions.assertFalse;
18+
import static org.junit.jupiter.api.Assertions.assertNotNull;
1919

2020
import org.eclipse.swt.accessibility.AccessibleControlEvent;
2121
import org.eclipse.swt.widgets.Shell;
22-
import org.junit.After;
23-
import org.junit.Before;
24-
import org.junit.Test;
22+
import org.junit.jupiter.api.AfterEach;
23+
import org.junit.jupiter.api.BeforeEach;
24+
import org.junit.jupiter.api.Test;
2525

2626
/**
2727
* Automated Test Suite for class org.eclipse.swt.accessibility.AccessibleControlEvent
@@ -30,12 +30,12 @@
3030
*/
3131
public class Test_org_eclipse_swt_accessibility_AccessibleControlEvent {
3232

33-
@Before
33+
@BeforeEach
3434
public void setUp() {
3535
shell = new Shell();
3636
}
3737

38-
@After
38+
@AfterEach
3939
public void tearDown() {
4040
shell.dispose();
4141
}
@@ -55,11 +55,9 @@ public void test_ConstructorLjava_lang_Object() {
5555
public void test_toString() {
5656
AccessibleControlEvent event = new AccessibleControlEvent(shell.getAccessible());
5757
assertNotNull(event.toString());
58-
assertTrue(event.toString().length() > 0);
58+
assertFalse(event.toString().isEmpty());
5959
}
6060

61-
62-
6361
/* custom */
6462
public Shell shell;
6563
}

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@
1414
*******************************************************************************/
1515
package org.eclipse.swt.tests.junit;
1616

17-
import static org.junit.Assert.assertNotNull;
18-
import static org.junit.Assert.assertTrue;
17+
import static org.junit.jupiter.api.Assertions.assertFalse;
18+
import static org.junit.jupiter.api.Assertions.assertNotNull;
1919

2020
import org.eclipse.swt.accessibility.AccessibleEvent;
2121
import org.eclipse.swt.widgets.Shell;
22-
import org.junit.After;
23-
import org.junit.Before;
24-
import org.junit.Test;
22+
import org.junit.jupiter.api.AfterEach;
23+
import org.junit.jupiter.api.BeforeEach;
24+
import org.junit.jupiter.api.Test;
2525

2626
/**
2727
* Automated Test Suite for class org.eclipse.swt.accessibility.AccessibleEvent
@@ -30,12 +30,12 @@
3030
*/
3131
public class Test_org_eclipse_swt_accessibility_AccessibleEvent {
3232

33-
@Before
33+
@BeforeEach
3434
public void setUp() {
3535
shell = new Shell();
3636
}
3737

38-
@After
38+
@AfterEach
3939
public void tearDown() {
4040
shell.dispose();
4141
}
@@ -55,7 +55,7 @@ public void test_ConstructorLjava_lang_Object() {
5555
public void test_toString() {
5656
AccessibleEvent event = new AccessibleEvent(shell.getAccessible());
5757
assertNotNull(event.toString());
58-
assertTrue(event.toString().length() > 0);
58+
assertFalse(event.toString().isEmpty());
5959
}
6060

6161
/* custom */

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@
1414
*******************************************************************************/
1515
package org.eclipse.swt.tests.junit;
1616

17-
import static org.junit.Assert.assertNotNull;
18-
import static org.junit.Assert.assertTrue;
17+
import static org.junit.jupiter.api.Assertions.assertFalse;
18+
import static org.junit.jupiter.api.Assertions.assertNotNull;
1919

2020
import org.eclipse.swt.accessibility.AccessibleTextEvent;
2121
import org.eclipse.swt.widgets.Shell;
22-
import org.junit.After;
23-
import org.junit.Before;
24-
import org.junit.Test;
22+
import org.junit.jupiter.api.AfterEach;
23+
import org.junit.jupiter.api.BeforeEach;
24+
import org.junit.jupiter.api.Test;
2525

2626
/**
2727
* Automated Test Suite for class org.eclipse.swt.accessibility.AccessibleTextEvent
@@ -30,12 +30,12 @@
3030
*/
3131
public class Test_org_eclipse_swt_accessibility_AccessibleTextEvent {
3232

33-
@Before
33+
@BeforeEach
3434
public void setUp() {
3535
shell = new Shell();
3636
}
3737

38-
@After
38+
@AfterEach
3939
public void tearDown() {
4040
shell.dispose();
4141
}
@@ -55,7 +55,7 @@ public void test_ConstructorLjava_lang_Object() {
5555
public void test_toString() {
5656
AccessibleTextEvent event = new AccessibleTextEvent(shell.getAccessible());
5757
assertNotNull(event.toString());
58-
assertTrue(event.toString().length() > 0);
58+
assertFalse(event.toString().isEmpty());
5959
}
6060
/* custom */
6161
public Shell shell;

0 commit comments

Comments
 (0)