Skip to content

Commit

Permalink
Migrate tests in org.eclipse.test.performance to JUnit 5
Browse files Browse the repository at this point in the history
The tests in org.eclipse.tests.performance are still written in JUnit 3,
i.e., the test classes extend TestCase.

* Migrates tests and test suite to JUnit 5.
* Adds the missing SimplePerformanceMeterTest to
the according test suite
  • Loading branch information
HeikoKlare authored and akurtakov committed Oct 22, 2023
1 parent 6b8de72 commit ba25cf0
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ Export-Package: org.eclipse.perfmsr.core,
org.eclipse.test.internal.performance.eval,
org.eclipse.test.internal.performance.tests,
org.eclipse.test.performance
Import-Package: org.junit.jupiter.api
Import-Package: org.junit.jupiter.api,
org.junit.platform.suite.api
Require-Bundle: org.eclipse.core.runtime,
org.junit
Bundle-ActivationPolicy: lazy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,11 @@

package org.eclipse.test.internal.performance.tests;

import junit.framework.Test;
import junit.framework.TestSuite;
import org.junit.platform.suite.api.SelectClasses;
import org.junit.platform.suite.api.Suite;

@Suite
@SelectClasses({ PerformanceMeterFactoryTest.class, SimplePerformanceMeterTest.class, VariationsTests.class })
public class AllTests {

public static Test suite() {
TestSuite suite = new TestSuite("Performance Test plugin tests"); //$NON-NLS-1$

// suite.addTestSuite(SimplePerformanceMeterTest.class);
suite.addTestSuite(VariationsTests.class);
suite.addTestSuite(PerformanceMeterFactoryTest.class);

return suite;
}
//
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,22 @@

package org.eclipse.test.internal.performance.tests;

import static org.junit.jupiter.api.Assertions.assertTrue;

import org.eclipse.test.internal.performance.OSPerformanceMeter;
import org.eclipse.test.performance.Performance;
import org.eclipse.test.performance.PerformanceMeter;
import org.junit.jupiter.api.Test;

import junit.framework.TestCase;

public class PerformanceMeterFactoryTest extends TestCase {
public class PerformanceMeterFactoryTest {

@Test
public void testPerformanceMeterFactory() {
System.setProperty(
"PerformanceMeterFactory", "org.eclipse.test.performance:org.eclipse.test.internal.performance.OSPerformanceMeterFactory"); //$NON-NLS-1$ //$NON-NLS-2$

Performance performance = Performance.getDefault();
PerformanceMeter pm = performance.createPerformanceMeter(performance.getDefaultScenarioId(this));
PerformanceMeter pm = performance.createPerformanceMeter(performance.getDefaultScenarioId(this.getClass()));

assertTrue(pm instanceof OSPerformanceMeter);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,19 @@

package org.eclipse.test.internal.performance.tests;

import static org.junit.jupiter.api.Assertions.assertTrue;

import org.eclipse.test.internal.performance.OSPerformanceMeter;
import org.eclipse.test.performance.Performance;
import org.eclipse.test.performance.PerformanceMeter;
import org.junit.jupiter.api.Test;

import junit.framework.TestCase;

public class SimplePerformanceMeterTest extends TestCase {
public class SimplePerformanceMeterTest {

@Test
public void testPerformanceMeterFactory() {
Performance performance = Performance.getDefault();
PerformanceMeter meter = performance.createPerformanceMeter(performance.getDefaultScenarioId(this));
PerformanceMeter meter = performance.createPerformanceMeter(performance.getDefaultScenarioId(this.getClass()));

assertTrue(meter instanceof OSPerformanceMeter);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@

package org.eclipse.test.internal.performance.tests;

import org.eclipse.test.internal.performance.db.Variations;
import static org.junit.jupiter.api.Assertions.assertEquals;

import junit.framework.TestCase;
import org.eclipse.test.internal.performance.db.Variations;
import org.junit.jupiter.api.Test;

public class VariationsTests extends TestCase {
public class VariationsTests {

@Test
public void testVariations() {
Variations v1 = new Variations();
v1.put("k1", "foo"); //$NON-NLS-1$ //$NON-NLS-2$
Expand All @@ -40,6 +42,7 @@ public void testVariations() {
assertEquals("%|k1=foo|%|k2=bar|%|k3=xyz|%", v3.toQueryPattern()); //$NON-NLS-1$
}

@Test
public void testParseVariations() {
Variations v1 = new Variations();
v1.put("k1", "foo"); //$NON-NLS-1$ //$NON-NLS-2$
Expand Down

0 comments on commit ba25cf0

Please sign in to comment.