Skip to content

Commit 403bf19

Browse files
committed
Convert changelog ui tests to JUNit 5
1 parent e31f9cf commit 403bf19

8 files changed

Lines changed: 71 additions & 82 deletions

File tree

changelog/org.eclipse.linuxtools.changelog.ui.tests/META-INF/MANIFEST.MF

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,14 @@ Bundle-SymbolicName: org.eclipse.linuxtools.changelog.ui.tests
55
Bundle-Version: 2.7.0.qualifier
66
Bundle-Vendor: Eclipse.org
77
Require-Bundle: org.eclipse.swtbot.go;bundle-version="4.0.0",
8-
org.eclipse.cdt.core
8+
org.eclipse.cdt.core,
9+
org.eclipse.swtbot.junit5_x;bundle-version="[4.3.0,5.0.0)"
910
Fragment-Host: org.eclipse.linuxtools.changelog.core
1011
Import-Package: org.eclipse.core.resources,
1112
org.eclipse.jdt.core,
13+
org.junit.jupiter.api;version="[5.14.0,6.0.0)",
14+
org.junit.jupiter.api.extension;version="[5.14.0,6.0.0)",
15+
org.junit.jupiter.api.function;version="[5.14.0,6.0.0)",
1216
org.slf4j
1317
Bundle-RequiredExecutionEnvironment: JavaSE-21
1418
Automatic-Module-Name: org.eclipse.linuxtools.changelog.ui.tests

changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/swtbot/AbstractSWTBotTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,18 @@
1515
import org.eclipse.linuxtools.changelog.ui.tests.utils.ProjectExplorer;
1616
import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
1717
import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
18-
import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
18+
import org.eclipse.swtbot.swt.finder.junit5.SWTBotJunit5Extension;
1919
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
20-
import org.junit.BeforeClass;
21-
import org.junit.runner.RunWith;
20+
import org.junit.jupiter.api.BeforeAll;
21+
import org.junit.jupiter.api.extension.ExtendWith;
2222

23-
@RunWith(SWTBotJunit4ClassRunner.class)
23+
@ExtendWith(SWTBotJunit5Extension.class)
2424
public abstract class AbstractSWTBotTest {
2525

2626
protected static SWTWorkbenchBot bot;
2727
protected static SWTBotTree projectExplorerViewTree;
2828

29-
@BeforeClass
29+
@BeforeAll
3030
public static void beforeClass() {
3131
// delay click speed
3232
//System.setProperty("org.eclipse.swtbot.playback.delay", "200");

changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/swtbot/AddChangelogEntrySWTBotTest.java

Lines changed: 21 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010
package org.eclipse.linuxtools.changelog.ui.tests.swtbot;
1111

1212
import static org.eclipse.swtbot.eclipse.finder.matchers.WidgetMatcherFactory.withPartName;
13-
import static org.junit.Assert.assertEquals;
14-
import static org.junit.Assert.assertNotNull;
15-
import static org.junit.Assert.assertNull;
16-
import static org.junit.Assert.assertTrue;
17-
import static org.junit.Assert.fail;
13+
import static org.junit.jupiter.api.Assertions.assertEquals;
14+
import static org.junit.jupiter.api.Assertions.assertNotNull;
15+
import static org.junit.jupiter.api.Assertions.assertNull;
16+
import static org.junit.jupiter.api.Assertions.assertThrows;
17+
import static org.junit.jupiter.api.Assertions.assertTrue;
1818

1919
import java.io.ByteArrayInputStream;
2020
import java.io.InputStream;
@@ -31,12 +31,10 @@
3131
import org.eclipse.swtbot.swt.finder.keyboard.Keystrokes;
3232
import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences;
3333
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
34-
import org.junit.After;
35-
import org.junit.Before;
36-
import org.junit.Ignore;
37-
import org.junit.Rule;
38-
import org.junit.Test;
39-
import org.junit.rules.TestName;
34+
import org.junit.jupiter.api.AfterEach;
35+
import org.junit.jupiter.api.BeforeEach;
36+
import org.junit.jupiter.api.Disabled;
37+
import org.junit.jupiter.api.Test;
4038

4139
/**
4240
* UI tests for "ChangeLog Entry" (CTRL+ALT+C).
@@ -48,18 +46,16 @@ public class AddChangelogEntrySWTBotTest extends AbstractSWTBotTest {
4846
private static final String OFFSET_MARKER = "<-- SELECT -->";
4947
// The name of the test project, we create
5048
private final String PROJECT_NAME = "changelog-java-project";
51-
@Rule
52-
public TestName name = new TestName();
5349

54-
@Before
50+
@BeforeEach
5551
public void setUp() throws Exception {
5652
// Create an empty test project
5753
project = new ChangeLogTestProject(PROJECT_NAME);
5854
project.addJavaNature(); // make it a Java project
5955
projectExplorerViewTree = ProjectExplorer.getTree();
6056
}
6157

62-
@After
58+
@AfterEach
6359
public void tearDown() throws Exception {
6460
this.project.getTestProject().delete(true, null);
6561
}
@@ -71,11 +67,10 @@ public void tearDown() throws Exception {
7167
*
7268
* @throws Exception
7369
*/
74-
@Ignore
70+
@Disabled
7571
@Test
7672
public void canAddChangeLogEntryUsingShortCutIfSourceIsActive() throws Exception {
7773
// Add a Java source file
78-
System.out.println(name.getMethodName());
7974
String sourceCode = "package src;\n" +
8075
"public class JavaTest {\n" +
8176
"public static void main(String args[]) {\n" +
@@ -179,28 +174,24 @@ public void canAddChangeLogEntryUsingEditMenuIfSourceIsActive() throws Exception
179174
}
180175

181176
/**
182-
* FIXME: Disable menu item instead of showing it and doing nothing.
183-
*
184-
* This test throws WidgetNotFountException (i.e. shouldn't open any editor).
185-
*/
186-
@Test(expected=WidgetNotFoundException.class)
187-
public void shouldDoNothingIfNoEditorIsActive() {
177+
* FIXME: Disable menu item instead of showing it and doing nothing.
178+
*
179+
* This test throws WidgetNotFountException (i.e. shouldn't open any editor).
180+
*/
181+
@Test
182+
public void shouldDoNothingIfNoEditorIsActive() throws CoreException {
188183
assertNull(project.getTestProject().findMember( new Path("/src/dummy")));
189-
try {
190-
project.addFileToProject("src", "dummy", new ByteArrayInputStream("".getBytes()));
191-
} catch (CoreException e) {
192-
fail("Could not add /src/dummy file to project");
193-
}
184+
project.addFileToProject("src", "dummy", new ByteArrayInputStream("".getBytes()));
194185
assertNotNull(project.getTestProject().findMember( new Path("/src/dummy")));
195186
// Make sure we are in the project explorer view and no editors are open
196187
bot.closeAllEditors();
197188
projectExplorerViewTree.expandNode(PROJECT_NAME).expandNode("src");
198189
// Try to create ChangeLog
199-
bot.menu("Edit").menu("ChangeLog Entry").click();
190+
assertThrows(WidgetNotFoundException.class, () -> bot.menu("Edit").menu("ChangeLog Entry").click());
200191
// Don't wait 5 secs
201192
long oldTimeout = SWTBotPreferences.TIMEOUT;
202193
SWTBotPreferences.TIMEOUT = 1000; // give it a full second :)
203-
bot.activeEditor();
194+
assertThrows(WidgetNotFoundException.class, () -> bot.activeEditor());
204195
SWTBotPreferences.TIMEOUT = oldTimeout;
205196
}
206197

changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/swtbot/CreateChangeLogFromHistorySWTBotTest.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
package org.eclipse.linuxtools.changelog.ui.tests.swtbot;
1111

1212
import static org.eclipse.swtbot.eclipse.finder.matchers.WidgetMatcherFactory.withPartName;
13-
import static org.junit.Assert.assertEquals;
14-
import static org.junit.Assert.assertFalse;
15-
import static org.junit.Assert.assertNotNull;
13+
import static org.junit.jupiter.api.Assertions.assertEquals;
14+
import static org.junit.jupiter.api.Assertions.assertFalse;
15+
import static org.junit.jupiter.api.Assertions.assertNotNull;
1616

1717
import java.io.ByteArrayInputStream;
1818

@@ -38,10 +38,10 @@
3838
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTable;
3939
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
4040
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
41-
import org.junit.After;
42-
import org.junit.Before;
43-
import org.junit.Ignore;
44-
import org.junit.Test;
41+
import org.junit.jupiter.api.AfterEach;
42+
import org.junit.jupiter.api.BeforeEach;
43+
import org.junit.jupiter.api.Disabled;
44+
import org.junit.jupiter.api.Test;
4545

4646
/**
4747
* UI tests for creating changelogs from SVN history (commit messages).
@@ -57,7 +57,7 @@ public class CreateChangeLogFromHistorySWTBotTest extends AbstractSWTBotTest {
5757
private final String SVN_PROJECT_URL = "svn://dev.eclipse.org/svnroot/technology/" +
5858
"org.eclipse.linuxtools/changelog/trunk";
5959

60-
@Before
60+
@BeforeEach
6161
public void setUp() throws Exception {
6262
// Do an SVN checkout of the changelog.tests plugin
6363
subversionProject = new SVNProject(bot);
@@ -66,7 +66,7 @@ public void setUp() throws Exception {
6666
ProjectExplorer.openView();
6767
}
6868

69-
@After
69+
@AfterEach
7070
public void tearDown() throws Exception {
7171
this.project.delete(true, null);
7272
// discard existing repo from previous test runs
@@ -83,7 +83,7 @@ public void tearDown() throws Exception {
8383
* @throws Exception
8484
*/
8585
@Test
86-
@Ignore
86+
@Disabled
8787
public void canPrepareChangeLogFromSVNHistory() throws Exception {
8888
// select ChangeLog file
8989
String teamProviderString = "[changelog/trunk/" + PROJECT_NAME + "]";

changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/swtbot/DisabledPrepareChangelogSWTBotTest.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
*******************************************************************************/
1010
package org.eclipse.linuxtools.changelog.ui.tests.swtbot;
1111

12-
import static org.junit.Assert.assertNotNull;
13-
import static org.junit.Assert.assertNull;
14-
import static org.junit.Assert.assertTrue;
15-
import static org.junit.Assert.fail;
12+
import static org.junit.jupiter.api.Assertions.assertNotNull;
13+
import static org.junit.jupiter.api.Assertions.assertNull;
14+
import static org.junit.jupiter.api.Assertions.assertTrue;
15+
import static org.junit.jupiter.api.Assertions.fail;
1616

1717
import java.io.ByteArrayInputStream;
1818

@@ -22,10 +22,10 @@
2222
import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences;
2323
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
2424
import org.eclipse.swtbot.swt.finder.widgets.TimeoutException;
25-
import org.junit.After;
26-
import org.junit.Before;
27-
import org.junit.Ignore;
28-
import org.junit.Test;
25+
import org.junit.jupiter.api.AfterEach;
26+
import org.junit.jupiter.api.BeforeEach;
27+
import org.junit.jupiter.api.Disabled;
28+
import org.junit.jupiter.api.Test;
2929

3030
/**
3131
* UI test for "Prepare ChangeLog" when project not shared.
@@ -35,12 +35,12 @@ public class DisabledPrepareChangelogSWTBotTest extends AbstractSWTBotTest {
3535
private final String projectName = "not-shared";
3636
private ChangeLogTestProject project;
3737

38-
@Before
38+
@BeforeEach
3939
public void setUp() throws Exception {
4040
project = new ChangeLogTestProject(projectName);
4141
}
4242

43-
@After
43+
@AfterEach
4444
public void tearDown() throws Exception {
4545
this.project.getTestProject().delete(true, null);
4646
}
@@ -52,7 +52,7 @@ public void tearDown() throws Exception {
5252
* @throws Exception
5353
*/
5454
@Test
55-
@Ignore
55+
@Disabled
5656
public void cannotPrepareChangeLogOnNonCVSOrSVNProject() throws Exception {
5757
assertNull(project.getTestProject().findMember(new Path("/ChangeLog")));
5858

changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/swtbot/FormatChangeLogSWTBotTest.java

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
package org.eclipse.linuxtools.changelog.ui.tests.swtbot;
1111

1212
import static org.eclipse.swtbot.eclipse.finder.matchers.WidgetMatcherFactory.withPartName;
13-
import static org.junit.Assert.assertEquals;
14-
import static org.junit.Assert.assertNotNull;
15-
import static org.junit.Assert.assertNull;
13+
import static org.junit.jupiter.api.Assertions.assertEquals;
14+
import static org.junit.jupiter.api.Assertions.assertNotNull;
15+
import static org.junit.jupiter.api.Assertions.assertNull;
1616

1717
import java.io.ByteArrayInputStream;
1818

@@ -27,9 +27,9 @@
2727
import org.eclipse.swtbot.swt.finder.keyboard.Keystrokes;
2828
import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences;
2929
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
30-
import org.junit.After;
31-
import org.junit.Before;
32-
import org.junit.Test;
30+
import org.junit.jupiter.api.AfterEach;
31+
import org.junit.jupiter.api.BeforeEach;
32+
import org.junit.jupiter.api.Test;
3333

3434
/**
3535
* UI tests for formatting ChangeLog files.
@@ -40,21 +40,19 @@ public class FormatChangeLogSWTBotTest extends AbstractSWTBotTest {
4040
// The name of the test project, we create
4141
private final String PROJECT_NAME = "org.eclipse.linuxtools.changelog.ui.formattestproject";
4242

43-
@Before
43+
@BeforeEach
4444
public void setUp() throws Exception {
4545
project = new ChangeLogTestProject(PROJECT_NAME);
4646
projectExplorerViewTree = ProjectExplorer.getTree();
4747
}
4848

49-
@After
49+
@AfterEach
5050
public void tearDown() throws Exception {
5151
this.project.getTestProject().delete(true, null);
5252
}
5353

5454
/**
5555
* Simple test for ChangeLog formatting.
56-
*
57-
* @throws Exception
5856
*/
5957
@Test
6058
public void canFormatChangeLogFile() throws Exception {

changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/swtbot/PrepareChangelogSWTBotTest.java

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
package org.eclipse.linuxtools.changelog.ui.tests.swtbot;
1111

1212
import static org.eclipse.swtbot.eclipse.finder.matchers.WidgetMatcherFactory.withPartName;
13-
import static org.junit.Assert.assertEquals;
14-
import static org.junit.Assert.assertNotNull;
15-
import static org.junit.Assert.assertTrue;
13+
import static org.junit.jupiter.api.Assertions.assertEquals;
14+
import static org.junit.jupiter.api.Assertions.assertNotNull;
15+
import static org.junit.jupiter.api.Assertions.assertTrue;
1616

1717
import java.io.ByteArrayInputStream;
1818

@@ -32,16 +32,16 @@
3232
import org.eclipse.swtbot.swt.finder.keyboard.Keystrokes;
3333
import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences;
3434
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
35-
import org.junit.After;
36-
import org.junit.Before;
37-
import org.junit.Ignore;
38-
import org.junit.Test;
35+
import org.junit.jupiter.api.AfterEach;
36+
import org.junit.jupiter.api.BeforeEach;
37+
import org.junit.jupiter.api.Disabled;
38+
import org.junit.jupiter.api.Test;
3939

4040
/**
4141
* UI tests for "Prepare ChangeLog" (CTRL+ALT+P) and the clipboard magic
4242
* (CTRL+ALT+V).
4343
*/
44-
@Ignore
44+
@Disabled
4545
public class PrepareChangelogSWTBotTest extends AbstractSWTBotTest {
4646

4747
private SVNProject subversionProject;
@@ -52,7 +52,7 @@ public class PrepareChangelogSWTBotTest extends AbstractSWTBotTest {
5252
private final String SVN_PROJECT_URL = "svn://dev.eclipse.org/svnroot/technology/" +
5353
"org.eclipse.linuxtools/changelog/trunk";
5454

55-
@Before
55+
@BeforeEach
5656
public void setUp() throws Exception {
5757
// Do an SVN checkout of the changelog.tests plugin
5858
subversionProject = new SVNProject(bot);
@@ -61,7 +61,7 @@ public void setUp() throws Exception {
6161
ProjectExplorer.openView();
6262
}
6363

64-
@After
64+
@AfterEach
6565
public void tearDown() throws Exception {
6666
this.project.delete(true, null);
6767
// discard existing repo from previous test runs
@@ -78,7 +78,6 @@ public void tearDown() throws Exception {
7878
* @throws Exception
7979
*/
8080
@Test
81-
@Ignore
8281
public void canPrepareChangeLog() throws Exception {
8382
// Find manifest file
8483
IResource manifest = project.findMember(new Path("/META-INF/MANIFEST.MF"));
@@ -111,11 +110,8 @@ public void canPrepareChangeLog() throws Exception {
111110
/**
112111
* Should be able to save changes to ChangeLog file in clipboard.
113112
* Tests CTRL + ALT + V functionality.
114-
*
115-
* @throws Exception
116113
*/
117114
@Test
118-
@Ignore
119115
public void canPrepareChangeLogAndSaveChangesInChangeLogFileToClipboard() throws Exception {
120116
// Find manifest file
121117
IResource manifest = project.findMember(new Path("/META-INF/MANIFEST.MF"));

changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/utils/SVNProject.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*******************************************************************************/
1010
package org.eclipse.linuxtools.changelog.ui.tests.utils;
1111

12-
import static org.junit.Assert.assertNotNull;
12+
import static org.junit.jupiter.api.Assertions.assertNotNull;
1313

1414
import org.eclipse.core.resources.IProject;
1515
import org.eclipse.core.resources.IResource;

0 commit comments

Comments
 (0)