Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate Ant UI performance tests to JUnit 5 #751

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

package org.eclipse.ant.tests.ui.editor.performance;

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

import java.io.File;

import org.eclipse.ant.internal.ui.AntUIPlugin;
Expand All @@ -26,29 +28,36 @@
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.test.performance.Dimension;
import org.eclipse.ui.PartInitException;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInfo;

@SuppressWarnings("restriction")
public class OpenAntEditorTest extends AbstractAntPerformanceTest {

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

@Test
public void testOpenAntEditor1() throws Exception {
// cold run
IFile file = getIFile("build.xml"); //$NON-NLS-1$
measureOpenInEditor(file);
}

@Test
public void testOpenAntEditor2() throws Exception {
// warm run
IFile file = getIFile("build.xml"); //$NON-NLS-1$
tagAsGlobalSummary("Open Ant Editor", Dimension.ELAPSED_PROCESS); //$NON-NLS-1$
measureOpenInEditor(file);
}

@Test
public void testOpenAntEditorNoFolding() throws Exception {
IPreferenceStore store = AntUIPlugin.getDefault().getPreferenceStore();
try {
Expand All @@ -68,13 +77,13 @@ protected IFile getIFile(String buildFileName) {

protected File getBuildFile(String buildFileName) {
IFile file = getIFile(buildFileName);
assertTrue("Could not find build file named: " + buildFileName, file.exists()); //$NON-NLS-1$
assertTrue(file.exists(), "Could not find build file named: " + buildFileName); //$NON-NLS-1$
return file.getLocation().toFile();
}

/**
* Returns the 'AntUITests' project.
*
*
* @return the test project
*/
protected IProject getProject() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,28 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.ant.tests.ui.performance;

import org.eclipse.ant.tests.ui.testplugin.AbstractAntUITest;
import org.eclipse.test.performance.PerformanceTestCase;
import org.eclipse.test.performance.PerformanceTestCaseJunit5;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.TestInfo;

/**
* Abstract class for ant performance tests, ensures the test project is created and ready in the test workspace.
*
*
* @since 3.5
*/
public abstract class AbstractAntPerformanceTest extends PerformanceTestCase {
public abstract class AbstractAntPerformanceTest extends PerformanceTestCaseJunit5 {

@BeforeEach
@Override
protected void setUp() throws Exception {
super.setUp();
public void setUp(TestInfo testInfo) throws Exception {
super.setUp(testInfo);
AbstractAntUITest.assertProject();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/

package org.eclipse.ant.tests.ui.performance;

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

import org.eclipse.ant.internal.ui.IAntUIConstants;
import org.eclipse.ant.tests.ui.editor.performance.EditorTestHelper;
import org.eclipse.ant.tests.ui.testplugin.AbstractAntUITest;
Expand All @@ -28,14 +30,19 @@
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.test.performance.Dimension;
import org.eclipse.test.performance.PerformanceTestCase;
import org.eclipse.test.performance.PerformanceTestCaseJunit5;
import org.eclipse.ui.externaltools.internal.model.IExternalToolConstants;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInfo;

@SuppressWarnings("restriction")
public class OpenLaunchConfigurationDialogTests extends PerformanceTestCase {
public class OpenLaunchConfigurationDialogTests extends PerformanceTestCaseJunit5 {

public static String fgIdentifier = IExternalToolConstants.ID_EXTERNAL_TOOLS_LAUNCH_GROUP;

@Test
public void testOpenAntLaunchConfigurationDialog1() {
// cold run
ILaunchConfiguration configuration = getLaunchConfiguration("big"); //$NON-NLS-1$
Expand All @@ -48,6 +55,7 @@ public void testOpenAntLaunchConfigurationDialog1() {
assertPerformance();
}

@Test
public void testOpenAntLaunchConfigurationDialog2() {
// warm run
ILaunchConfiguration configuration = getLaunchConfiguration("big"); //$NON-NLS-1$
Expand All @@ -64,7 +72,7 @@ public void testOpenAntLaunchConfigurationDialog2() {
private ILaunchConfiguration getLaunchConfiguration(String buildFileName) {
IFile file = AbstractAntUITest.getJavaProject().getProject().getFolder("launchConfigurations").getFile(buildFileName + ".launch"); //$NON-NLS-1$ //$NON-NLS-2$
ILaunchConfiguration config = AbstractAntUITest.getLaunchManager().getLaunchConfiguration(file);
assertTrue("Could not find launch configuration for " + buildFileName, config.exists()); //$NON-NLS-1$
assertTrue(config.exists(), "Could not find launch configuration for " + buildFileName); //$NON-NLS-1$
return config;
}

Expand All @@ -86,9 +94,10 @@ private void openLCD(final IStructuredSelection selection, final String groupIde
stopMeasuring();
}

@BeforeEach
@Override
protected void setUp() throws Exception {
super.setUp();
public void setUp(TestInfo testInfo) throws Exception {
super.setUp(testInfo);
IPreferenceStore debugPreferenceStore = DebugUIPlugin.getDefault().getPreferenceStore();
debugPreferenceStore.setValue(IInternalDebugUIConstants.PREF_FILTER_LAUNCH_CLOSED, false);
debugPreferenceStore.setValue(IInternalDebugUIConstants.PREF_FILTER_LAUNCH_DELETED, false);
Expand All @@ -97,8 +106,9 @@ protected void setUp() throws Exception {
EditorTestHelper.runEventQueue();
}

@AfterEach
@Override
protected void tearDown() throws Exception {
public void tearDown() throws Exception {
super.tearDown();
IPreferenceStore debugPreferenceStore = DebugUIPlugin.getDefault().getPreferenceStore();
debugPreferenceStore.setToDefault(IInternalDebugUIConstants.PREF_FILTER_LAUNCH_CLOSED);
Expand Down
2 changes: 2 additions & 0 deletions ant/org.eclipse.ant.tests.ui/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ Require-Bundle: org.eclipse.ui.ide;resolution:=optional,
org.eclipse.ant.launching,
org.eclipse.core.externaltools,
org.eclipse.pde.core
Import-Package: org.junit.jupiter.api,
org.junit.platform.suite.api
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-17
Eclipse-BundleShape: dir
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,26 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/

package org.eclipse.ant.tests.ui.testplugin;

import org.eclipse.ant.tests.ui.editor.performance.OpenAntEditorTest;
import org.eclipse.ant.tests.ui.performance.OpenLaunchConfigurationDialogTests;
import org.eclipse.ant.tests.ui.performance.SeparateVMTests;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.platform.suite.api.SelectClasses;
import org.junit.platform.suite.api.Suite;

/**
* Performance Test suite for the Ant UI. All of the tests in this suite rely on
* the setup that occurs in the ProjectCreationDecorator suite. It must always
* run before any of the other test suites.
*/
@RunWith(Suite.class)
@Suite.SuiteClasses({ OpenAntEditorTest.class, SeparateVMTests.class })
@Suite
@SelectClasses({ OpenAntEditorTest.class, OpenLaunchConfigurationDialogTests.class, SeparateVMTests.class })
public class AntUIPerformanceTests {
// suite.addTest(new TestSuite(NonInitialTypingTest.class));
// suite.addTest(new TestSuite(OpenLaunchConfigurationDialogTests.class));
//
}
Loading