Skip to content

Commit

Permalink
Migrate UA performance tests to JUnit 5
Browse files Browse the repository at this point in the history
The performance tests in org.eclipse.ua.tests still rely on the JUnit 3
PerformanceTestCase. In addition, one test class is missing in an
according test suite.

* Migrates all UA performance tests and test suites to JUnit 5
* Adds the missing LowIterationHelpServerTest to the
AllHelpPerformanceTests suite
  • Loading branch information
HeikoKlare committed Oct 20, 2023
1 parent cfb3c5f commit c68ec5d
Show file tree
Hide file tree
Showing 12 changed files with 98 additions and 52 deletions.
4 changes: 3 additions & 1 deletion ua/org.eclipse.ua.tests/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ Require-Bundle: org.junit,
Bundle-ActivationPolicy: lazy
Bundle-Vendor: Eclipse.org
Import-Package: javax.servlet;version="3.1.0",
javax.servlet.http;version="3.1.0"
javax.servlet.http;version="3.1.0",
org.junit.jupiter.api,
org.junit.platform.suite.api
Bundle-RequiredExecutionEnvironment: JavaSE-17
Export-Package: org.eclipse.ua.tests,
org.eclipse.ua.tests.browser.servlet,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,14 @@
package org.eclipse.ua.tests.cheatsheet;

import org.eclipse.ua.tests.cheatsheet.performance.OpenCheatSheetTest;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;
import org.junit.platform.suite.api.SelectClasses;
import org.junit.platform.suite.api.Suite;

/*
* Tests help performance (automated).
*/
@RunWith(Suite.class)
@SuiteClasses({ OpenCheatSheetTest.class })
@Suite
@SelectClasses({ OpenCheatSheetTest.class })
public class AllCheatSheetPerformanceTests {

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,27 @@

import org.eclipse.swt.widgets.Display;
import org.eclipse.test.performance.Dimension;
import org.eclipse.test.performance.PerformanceTestCase;
import org.eclipse.test.performance.PerformanceTestCaseJunit5;
import org.eclipse.ua.tests.intro.performance.OpenIntroTest;
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.cheatsheets.OpenCheatSheetAction;
import org.eclipse.ui.internal.cheatsheets.ICheatSheetResource;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInfo;

public class OpenCheatSheetTest extends PerformanceTestCase {
public class OpenCheatSheetTest extends PerformanceTestCaseJunit5 {

@BeforeEach
@Override
protected void setUp() throws Exception {
super.setUp();
public void setUp(TestInfo testInfo) throws Exception {
super.setUp(testInfo);
OpenIntroTest.closeIntro();
}

@Test
public void testOpenSimpleCheatSheet() throws Exception {
tagAsSummary("Open simple cheat sheet", Dimension.ELAPSED_PROCESS);

Expand All @@ -52,6 +57,7 @@ public void testOpenSimpleCheatSheet() throws Exception {
assertPerformance();
}

@Test
public void testOpenCompositeCheatSheet() throws Exception {
tagAsSummary("Open composite cheat sheet", Dimension.ELAPSED_PROCESS);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,22 @@
import org.eclipse.ua.tests.help.performance.BuildHtmlSearchIndex;
import org.eclipse.ua.tests.help.performance.HelpServerTest;
import org.eclipse.ua.tests.help.performance.IndexAssemblePerformanceTest;
import org.eclipse.ua.tests.help.performance.LowIterationHelpServerTest;
import org.eclipse.ua.tests.help.performance.TocAssemblePerformanceTest;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;
import org.junit.platform.suite.api.SelectClasses;
import org.junit.platform.suite.api.Suite;

/*
* Tests help performance (automated).
*/
@RunWith(Suite.class)
@SuiteClasses({ TocAssemblePerformanceTest.class, IndexAssemblePerformanceTest.class, BuildHtmlSearchIndex.class,
HelpServerTest.class })
@Suite
@SelectClasses({ TocAssemblePerformanceTest.class,
IndexAssemblePerformanceTest.class,
LowIterationHelpServerTest.class,
BuildHtmlSearchIndex.class,
HelpServerTest.class,
// OpenHelpTest.class // Disabled due to inability to get reliable results. Browser/SWT changes in timing of listener events no longer consistent in 3.3.
})
public class AllHelpPerformanceTests {

/*
* Disabled due to inability to get reliable results. Browser/SWT changes in
* timing of listener events no longer consistent in 3.3.
*/

// addTest(OpenHelpTest.suite());
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
*******************************************************************************/
package org.eclipse.ua.tests.help.performance;

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

import java.net.URL;

import org.eclipse.core.runtime.IStatus;
Expand All @@ -28,18 +30,23 @@
import org.eclipse.help.internal.toc.TocFileProvider;
import org.eclipse.help.internal.toc.TocManager;
import org.eclipse.test.performance.Dimension;
import org.eclipse.test.performance.PerformanceTestCase;
import org.eclipse.test.performance.PerformanceTestCaseJunit5;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInfo;
import org.osgi.framework.FrameworkUtil;

public class BuildHtmlSearchIndex extends PerformanceTestCase {
public class BuildHtmlSearchIndex extends PerformanceTestCaseJunit5 {

private AbstractTocProvider[] tocProviders;
private AbstractIndexProvider[] indexProviders;
private AnalyzerDescriptor analyzerDesc;

@BeforeEach
@Override
protected void setUp() throws Exception {
super.setUp();
public void setUp(TestInfo testInfo) throws Exception {
super.setUp(testInfo);
TocManager tocManager = HelpPlugin.getTocManager();
tocProviders = tocManager.getTocProviders();
tocManager.setTocProviders(new AbstractTocProvider[] { new TestTocFileProvider() });
Expand All @@ -52,8 +59,9 @@ protected void setUp() throws Exception {
analyzerDesc = new AnalyzerDescriptor("en-us");
}

@AfterEach
@Override
protected void tearDown() throws Exception {
public void tearDown() throws Exception {
super.tearDown();
TocManager tocManager = HelpPlugin.getTocManager();
tocManager.setTocProviders(tocProviders);
Expand All @@ -67,6 +75,7 @@ protected void tearDown() throws Exception {
indexProviders = null;
}

@Test
public void testCreateHtmlSearchIndex() throws Exception {
tagAsGlobalSummary("Create HTML Search Index", Dimension.ELAPSED_PROCESS);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,25 @@
package org.eclipse.ua.tests.help.performance;

import org.eclipse.test.performance.Dimension;
import org.eclipse.test.performance.PerformanceTestCase;
import org.eclipse.test.performance.PerformanceTestCaseJunit5;
import org.eclipse.ua.tests.help.util.LoadServletUtil;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;

/**
* Test the performance of the help server without launching the Help UI
*/

public class HelpServerTest extends PerformanceTestCase {
public class HelpServerTest extends PerformanceTestCaseJunit5 {

@AfterEach
@Override
protected void tearDown() throws Exception {
public void tearDown() throws Exception {
LoadServletUtil.stopServer();
super.tearDown();
}

@Test
public void testServletRead100x() throws Exception {
tagAsSummary("Servlet Read", Dimension.ELAPSED_PROCESS);
LoadServletUtil.startServer();
Expand All @@ -53,6 +57,7 @@ public void testServletRead100x() throws Exception {
assertPerformance();
}

@Test
public void testStartServer() throws Exception {
tagAsSummary("Start Server", Dimension.ELAPSED_PROCESS);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
*******************************************************************************/
package org.eclipse.ua.tests.help.performance;

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

import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
Expand All @@ -27,12 +29,14 @@
import org.eclipse.help.internal.index.IndexFile;
import org.eclipse.help.internal.index.IndexFileParser;
import org.eclipse.test.performance.Dimension;
import org.eclipse.test.performance.PerformanceTestCase;
import org.eclipse.test.performance.PerformanceTestCaseJunit5;
import org.junit.jupiter.api.Test;
import org.osgi.framework.FrameworkUtil;
import org.xml.sax.SAXException;

public class IndexAssemblePerformanceTest extends PerformanceTestCase {
public class IndexAssemblePerformanceTest extends PerformanceTestCaseJunit5 {

@Test
public void testIndexAssemble() throws Exception {
tagAsSummary("Assemble Index", Dimension.ELAPSED_PROCESS);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,25 @@
package org.eclipse.ua.tests.help.performance;

import org.eclipse.test.performance.Dimension;
import org.eclipse.test.performance.PerformanceTestCase;
import org.eclipse.test.performance.PerformanceTestCaseJunit5;
import org.eclipse.ua.tests.help.util.LoadServletUtil;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;

/**
* A version of the servlet read test with a low iteration count
*/

public class LowIterationHelpServerTest extends PerformanceTestCase {
public class LowIterationHelpServerTest extends PerformanceTestCaseJunit5 {

@AfterEach
@Override
protected void tearDown() throws Exception {
public void tearDown() throws Exception {
LoadServletUtil.stopServer();
super.tearDown();
}

@Test
public void testServletRead20x() throws Exception {
tagAsSummary("Servlet Read", Dimension.ELAPSED_PROCESS);
LoadServletUtil.startServer();
Expand All @@ -53,6 +57,7 @@ public void testServletRead20x() throws Exception {
assertPerformance();
}

@Test
public void testStartServer() throws Exception {
tagAsSummary("Start Server", Dimension.ELAPSED_PROCESS);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,24 @@
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.test.performance.Dimension;
import org.eclipse.test.performance.PerformanceTestCase;
import org.eclipse.test.performance.PerformanceTestCaseJunit5;
import org.eclipse.ui.PlatformUI;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInfo;
import org.osgi.framework.FrameworkUtil;

public class OpenHelpTest extends PerformanceTestCase {
public class OpenHelpTest extends PerformanceTestCaseJunit5 {

private AbstractTocProvider[] tocProviders;
private AbstractIndexProvider[] indexProviders;
private Shell shell;

@BeforeEach
@Override
protected void setUp() throws Exception {
super.setUp();
public void setUp(TestInfo testInfo) throws Exception {
super.setUp(testInfo);
TocManager tocManager = HelpPlugin.getTocManager();
tocProviders = tocManager.getTocProviders();
tocManager.setTocProviders(new AbstractTocProvider[] { new TestTocFileProvider() });
Expand All @@ -55,8 +60,9 @@ protected void setUp() throws Exception {
indexManager.clearCache();
}

@AfterEach
@Override
protected void tearDown() throws Exception {
public void tearDown() throws Exception {
super.tearDown();
TocManager tocManager = HelpPlugin.getTocManager();
tocManager.setTocProviders(tocProviders);
Expand All @@ -67,6 +73,7 @@ protected void tearDown() throws Exception {
indexManager.clearCache();
}

@Test
public void testOpenHelp() throws Exception {
tagAsGlobalSummary("Open help", Dimension.ELAPSED_PROCESS);

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

package org.eclipse.ua.tests.help.performance;

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

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
Expand All @@ -26,11 +28,12 @@
import org.eclipse.help.internal.toc.TocFile;
import org.eclipse.help.internal.toc.TocFileParser;
import org.eclipse.test.performance.Dimension;
import org.eclipse.test.performance.PerformanceTestCase;
import org.eclipse.test.performance.PerformanceTestCaseJunit5;
import org.junit.jupiter.api.Test;
import org.osgi.framework.FrameworkUtil;
import org.xml.sax.SAXException;

public class TocAssemblePerformanceTest extends PerformanceTestCase {
public class TocAssemblePerformanceTest extends PerformanceTestCaseJunit5 {

private TocContribution parse(TocFileParser parser, String tocFile)
throws IOException, SAXException, ParserConfigurationException {
Expand Down Expand Up @@ -64,6 +67,7 @@ private int countTopics(ITopic[] topics) {
return result;
}

@Test
public void testTocAssemble() throws Exception {
tagAsSummary("Assemble TOC", Dimension.ELAPSED_PROCESS);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,13 @@
package org.eclipse.ua.tests.intro;

import org.eclipse.ua.tests.intro.performance.OpenIntroTest;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;
import org.junit.platform.suite.api.SelectClasses;
import org.junit.platform.suite.api.Suite;

/*
* Tests help performance (automated).
*/
@RunWith(Suite.class)
@SuiteClasses({ OpenIntroTest.class })
@Suite
@SelectClasses({ OpenIntroTest.class })
public class AllIntroPerformanceTests {
}
Loading

0 comments on commit c68ec5d

Please sign in to comment.