From 2466dc21c37932c4dd996801980ff70820663b18 Mon Sep 17 00:00:00 2001 From: Heiko Klare Date: Fri, 20 Oct 2023 09:53:04 +0200 Subject: [PATCH] Migrate compare performance tests to JUnit 5 The performance test in org.eclipse.compare.tests still relies on the JUnit 3 PerformanceTestCase. This change migrates the compare performance test and test suite to JUnit 5. --- .../META-INF/MANIFEST.MF | 2 ++ .../tests/performance/PerformanceTestSuite.java | 15 ++++++--------- .../tests/performance/RangeDifferencerTest.java | 12 ++++++------ 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/team/tests/org.eclipse.compare.tests/META-INF/MANIFEST.MF b/team/tests/org.eclipse.compare.tests/META-INF/MANIFEST.MF index 146fd74a31e..0591074b76c 100644 --- a/team/tests/org.eclipse.compare.tests/META-INF/MANIFEST.MF +++ b/team/tests/org.eclipse.compare.tests/META-INF/MANIFEST.MF @@ -15,6 +15,8 @@ Require-Bundle: org.junit, org.eclipse.core.tests.harness, org.eclipse.core.filesystem, org.eclipse.team.ui +Import-Package: org.junit.jupiter.api, + org.junit.platform.suite.api Bundle-Activator: org.eclipse.compare.tests.CompareTestPlugin Bundle-ActivationPolicy: lazy Bundle-Vendor: %providerName diff --git a/team/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/performance/PerformanceTestSuite.java b/team/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/performance/PerformanceTestSuite.java index ce6ffcf945c..ba23144f6ad 100644 --- a/team/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/performance/PerformanceTestSuite.java +++ b/team/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/performance/PerformanceTestSuite.java @@ -13,19 +13,16 @@ *******************************************************************************/ package org.eclipse.compare.tests.performance; -import junit.framework.Test; +import org.junit.platform.suite.api.SelectClasses; +import org.junit.platform.suite.api.Suite; + import junit.framework.TestSuite; /** * @since 3.1 */ +@Suite +@SelectClasses({RangeDifferencerTest.class}) public class PerformanceTestSuite extends TestSuite { - - public static Test suite() { - TestSuite suite= new TestSuite("Compare performance tests"); //$NON-NLS-1$ - //$JUnit-BEGIN$ - suite.addTestSuite(RangeDifferencerTest.class); - //$JUnit-END$ - return suite; - } + // } diff --git a/team/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/performance/RangeDifferencerTest.java b/team/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/performance/RangeDifferencerTest.java index 105d9195305..21a0b755549 100644 --- a/team/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/performance/RangeDifferencerTest.java +++ b/team/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/performance/RangeDifferencerTest.java @@ -13,6 +13,8 @@ *******************************************************************************/ package org.eclipse.compare.tests.performance; +import static org.junit.jupiter.api.Assertions.assertEquals; + import org.eclipse.compare.contentmergeviewer.ITokenComparator; import org.eclipse.compare.internal.DocLineComparator; import org.eclipse.compare.rangedifferencer.RangeDifference; @@ -21,17 +23,14 @@ import org.eclipse.jface.text.Document; import org.eclipse.jface.text.IDocument; import org.eclipse.test.performance.Dimension; -import org.eclipse.test.performance.PerformanceTestCase; +import org.eclipse.test.performance.PerformanceTestCaseJunit5; +import org.junit.jupiter.api.Test; -public class RangeDifferencerTest extends PerformanceTestCase { +public class RangeDifferencerTest extends PerformanceTestCaseJunit5 { // static private final String EXPLANATION = "Performance decrease caused by changes in the compare framework, see bug 210688"; - public RangeDifferencerTest(String name) { - super(name); - } - /* * Creates document with 5000 lines. * Parameter code determines where additional lines are added. @@ -62,6 +61,7 @@ private IDocument createDocument(int code) { return new Document(sb.toString()); } + @Test public void testLargeDocument() { tagAsGlobalSummary("3-way compare, 5000 lines", Dimension.ELAPSED_PROCESS); //$NON-NLS-1$