Skip to content

Commit 699a7f6

Browse files
committed
Migrate org.eclipse.compare.tests to JUnit 5 #903
Migrates the tests in org.eclipse.compare.tests to JUnit 5. This consists of a replacement of the according annotations, migration of assertions, and the replacement of the JUnit 4 WorkspaceTestRule with the JUnit 5 WorkspaceResetExtension. The org.junit dependency is removed from the test bundle. Contributes to #903
1 parent e0be5f5 commit 699a7f6

21 files changed

+63
-89
lines changed

resources/tests/org.eclipse.core.tests.resources/META-INF/MANIFEST.MF

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ Export-Package: org.eclipse.core.tests.filesystem,
2727
org.eclipse.core.tests.resources.refresh,
2828
org.eclipse.core.tests.resources.regression,
2929
org.eclipse.core.tests.resources.session,
30-
org.eclipse.core.tests.resources.usecase
30+
org.eclipse.core.tests.resources.usecase,
31+
org.eclipse.core.tests.resources.util
3132
Require-Bundle: org.eclipse.core.resources,
3233
org.eclipse.core.tests.harness,
3334
org.junit,

team/tests/org.eclipse.compare.tests/META-INF/MANIFEST.MF

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ Bundle-ManifestVersion: 2
33
Bundle-Name: %pluginName
44
Bundle-SymbolicName: org.eclipse.compare.tests;singleton:=true
55
Bundle-Version: 3.8.400.qualifier
6-
Require-Bundle: org.junit,
7-
org.eclipse.compare,
6+
Require-Bundle: org.eclipse.compare,
87
org.eclipse.jface.text,
98
org.eclipse.jface,
109
org.eclipse.core.runtime;bundle-version="[3.29.0,4.0.0)",
@@ -18,6 +17,7 @@ Require-Bundle: org.junit,
1817
Import-Package: org.assertj.core.api,
1918
org.assertj.core.api.iterable,
2019
org.junit.jupiter.api,
20+
org.junit.jupiter.api.extension,
2121
org.junit.platform.suite.api
2222
Bundle-Activator: org.eclipse.compare.tests.CompareTestPlugin
2323
Bundle-ActivationPolicy: lazy

team/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/AllCompareTests.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,15 @@
1313
*******************************************************************************/
1414
package org.eclipse.compare.tests;
1515

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

2019
/**
2120
* Test some non-UI areas of the compare plug-in.
2221
*/
23-
24-
@RunWith(Suite.class)
2522
@SuppressWarnings("deprecation")
26-
@SuiteClasses({
23+
@Suite
24+
@SelectClasses({
2725
TextMergeViewerTest.class,
2826
LineReaderTest.class,
2927
StreamMergerTest.class,

team/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/AsyncExecTests.java

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

1616
import static org.assertj.core.api.Assertions.assertThat;
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 java.util.ArrayList;
2222
import java.util.List;
@@ -27,7 +27,7 @@
2727
import org.eclipse.core.runtime.NullProgressMonitor;
2828
import org.eclipse.core.runtime.OperationCanceledException;
2929
import org.eclipse.jface.operation.IRunnableWithProgress;
30-
import org.junit.Test;
30+
import org.junit.jupiter.api.Test;
3131

3232
public class AsyncExecTests {
3333

team/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/CompareFileRevisionEditorInputTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import org.eclipse.swt.graphics.Image;
2222
import org.eclipse.team.internal.ui.history.CompareFileRevisionEditorInput;
2323
import org.eclipse.ui.IWorkbenchPage;
24-
import org.junit.Test;
24+
import org.junit.jupiter.api.Test;
2525

2626
public class CompareFileRevisionEditorInputTest {
2727
@Test

team/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/CompareUIPluginTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
import org.eclipse.compare.structuremergeviewer.DiffNode;
2727
import org.eclipse.core.runtime.CoreException;
2828
import org.eclipse.swt.graphics.Image;
29-
import org.junit.Test;
29+
import org.junit.jupiter.api.Test;
3030

3131
public class CompareUIPluginTest {
3232

team/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/ContentMergeViewerTest.java

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

16-
import static org.junit.Assert.assertFalse;
17-
import static org.junit.Assert.assertTrue;
16+
import static org.junit.jupiter.api.Assertions.assertFalse;
17+
import static org.junit.jupiter.api.Assertions.assertTrue;
1818

1919
import org.eclipse.compare.CompareConfiguration;
2020
import org.eclipse.compare.contentmergeviewer.ContentMergeViewer;
2121
import org.eclipse.swt.widgets.Composite;
22-
import org.junit.Before;
23-
import org.junit.Test;
22+
import org.junit.jupiter.api.BeforeEach;
23+
import org.junit.jupiter.api.Test;
2424

2525
public class ContentMergeViewerTest {
2626
private MyContentMergeViewer myContentMergeViewer;
@@ -91,7 +91,7 @@ protected void updateContent(Object ancestor, Object left, Object right) {
9191
}
9292
}
9393

94-
@Before
94+
@BeforeEach
9595
public void setUp() {
9696
result = new boolean[] { false, false };
9797
myContentMergeViewer = new MyContentMergeViewer();

team/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/DiffTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import org.eclipse.core.runtime.SubMonitor;
2424
import org.eclipse.jface.text.Document;
2525
import org.eclipse.jface.text.IDocument;
26-
import org.junit.Test;
26+
import org.junit.jupiter.api.Test;
2727

2828
public class DiffTest {
2929

team/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/DocLineComparatorTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
package org.eclipse.compare.tests;
1515

1616
import static org.assertj.core.api.Assertions.assertThat;
17-
import static org.junit.Assert.assertFalse;
18-
import static org.junit.Assert.assertTrue;
17+
import static org.junit.jupiter.api.Assertions.assertFalse;
18+
import static org.junit.jupiter.api.Assertions.assertTrue;
1919

2020
import java.util.HashMap;
2121
import java.util.Optional;
@@ -27,7 +27,7 @@
2727
import org.eclipse.jface.text.IDocument;
2828
import org.eclipse.jface.text.IRegion;
2929
import org.eclipse.jface.text.Region;
30-
import org.junit.Test;
30+
import org.junit.jupiter.api.Test;
3131

3232
public class DocLineComparatorTest {
3333

team/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/FileDiffResultTest.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,13 @@
4444
import org.eclipse.core.resources.IStorage;
4545
import org.eclipse.core.resources.ResourcesPlugin;
4646
import org.eclipse.core.runtime.CoreException;
47-
import org.eclipse.core.tests.resources.WorkspaceTestRule;
48-
import org.junit.Rule;
49-
import org.junit.Test;
47+
import org.eclipse.core.tests.resources.util.WorkspaceResetExtension;
48+
import org.junit.jupiter.api.Test;
49+
import org.junit.jupiter.api.extension.ExtendWith;
5050

51+
@ExtendWith(WorkspaceResetExtension.class)
5152
public class FileDiffResultTest {
5253

53-
@Rule
54-
public WorkspaceTestRule workspaceRule = new WorkspaceTestRule();
55-
5654
private static final String PATCH_FILE = "patchfile";
5755

5856
private static final String NEW_FILENAME = "newfile";

0 commit comments

Comments
 (0)