From ab1880153b443ac5fb983859987f3226f7fdc935 Mon Sep 17 00:00:00 2001 From: Maxim Musienko Date: Tue, 19 Sep 2017 17:39:31 +0300 Subject: [PATCH 1/9] add new steps, locators and methods for the tests --- .../che/selenium/pageobject/Consoles.java | 16 +- ...ginJuinit4CheckRunSuitesAndScopesTest.java | 140 ++++++++++++++++++ .../testrunner/JavaTestPluginJunit4Test.java | 45 +++--- .../testrunner/JavaTestPluginTestNgTest.java | 34 ++++- 4 files changed, 211 insertions(+), 24 deletions(-) create mode 100644 selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/testrunner/JavaTestPluginJuinit4CheckRunSuitesAndScopesTest.java diff --git a/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/pageobject/Consoles.java b/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/pageobject/Consoles.java index dba19aad84a..f009b5a95f9 100644 --- a/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/pageobject/Consoles.java +++ b/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/pageobject/Consoles.java @@ -24,6 +24,7 @@ import org.eclipse.che.selenium.core.SeleniumWebDriver; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; +import org.openqa.selenium.interactions.Actions; import org.openqa.selenium.support.FindBy; import org.openqa.selenium.support.PageFactory; import org.openqa.selenium.support.ui.ExpectedConditions; @@ -59,9 +60,9 @@ public class Consoles { public static final String PREVIEW_URL = "//div[@active]//a[@href]"; public static final String COMMAND_CONSOLE_ID = "//div[@active]//div[@id='gwt-debug-commandConsoleLines']"; - protected final SeleniumWebDriver seleniumWebDriver; private final Loader loader; + private static final String CONSOLE_PANEL_DRUGGER_CSS = "div.gwt-SplitLayoutPanel-VDragger"; @Inject public Consoles(SeleniumWebDriver seleniumWebDriver, Loader loader) { @@ -72,6 +73,8 @@ public Consoles(SeleniumWebDriver seleniumWebDriver, Loader loader) { updateProjDriverWait = new WebDriverWait(seleniumWebDriver, UPDATING_PROJECT_TIMEOUT_SEC); PageFactory.initElements(seleniumWebDriver, this); } + @FindBy(css = CONSOLE_PANEL_DRUGGER_CSS) + WebElement consolesPanelDrugger; @FindBy(id = PROCESSES_TAB) WebElement processesTab; @@ -300,4 +303,15 @@ public boolean processesMainAreaIsOpen() { public void clickOnMaximizePanelIcon() { redrawDriverWait.until(elementToBeClickable(By.xpath(MAXIMIZE_PANEL_ICON))).click(); } + + /** + * * apply drug and drop feature for consoles feature, shift the work bench panel up or down + * + * @param xoffset offset in pixels for shifting + */ + public void drugConsolesInDefinePosition(int xoffset) { + WebElement drugger = + redrawDriverWait.until(ExpectedConditions.visibilityOf(consolesPanelDrugger)); + new Actions(seleniumWebDriver).dragAndDropBy(drugger, xoffset, xoffset).perform(); + } } diff --git a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/testrunner/JavaTestPluginJuinit4CheckRunSuitesAndScopesTest.java b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/testrunner/JavaTestPluginJuinit4CheckRunSuitesAndScopesTest.java new file mode 100644 index 00000000000..e7d2cd5fdb4 --- /dev/null +++ b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/testrunner/JavaTestPluginJuinit4CheckRunSuitesAndScopesTest.java @@ -0,0 +1,140 @@ +/* + * Copyright (c) 2012-2017 Red Hat, Inc. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Red Hat, Inc. - initial API and implementation + */ +package org.eclipse.che.selenium.testrunner; + +import com.google.inject.Inject; + +import org.eclipse.che.api.workspace.server.DtoConverter; +import org.eclipse.che.selenium.core.client.TestCommandServiceClient; +import org.eclipse.che.selenium.core.client.TestProjectServiceClient; +import org.eclipse.che.selenium.core.constant.TestMenuCommandsConstants; +import org.eclipse.che.selenium.core.project.ProjectTemplates; +import org.eclipse.che.selenium.core.workspace.InjectTestWorkspace; +import org.eclipse.che.selenium.core.workspace.TestWorkspace; +import org.eclipse.che.selenium.core.workspace.WorkspaceTemplate; +import org.eclipse.che.selenium.pageobject.CodenvyEditor; +import org.eclipse.che.selenium.pageobject.Consoles; +import org.eclipse.che.selenium.pageobject.Ide; +import org.eclipse.che.selenium.pageobject.Loader; +import org.eclipse.che.selenium.pageobject.Menu; +import org.eclipse.che.selenium.pageobject.NotificationsPopupPanel; +import org.eclipse.che.selenium.pageobject.ProjectExplorer; +import org.eclipse.che.selenium.pageobject.intelligent.CommandsPalette; +import org.eclipse.che.selenium.pageobject.plugins.JavaTestRunnerPluginConsole; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import java.nio.file.Paths; + + + + +import static org.testng.Assert.assertTrue; + +public class JavaTestPluginJuinit4CheckRunSuitesAndScopesTest { + private static final String JUNIT4_PROJECT = "junit4-tests-with-separeted-suites"; + + private static final String PATH_TO_JUNIT4_TEST_CLASSES = + JUNIT4_PROJECT + "/src/test/java/org/eclipse/che/tests/AppOneTest.java"; + private static final String PATH_TO_JUNIT4_TEST_SUITE = + JUNIT4_PROJECT + "/src/tests/java/org/examples/suite/Junit4TestSuite.java"; + + @Inject private JavaTestRunnerPluginConsole pluginConsole; + @Inject private ProjectExplorer projectExplorer; + @Inject private Loader loader; + @Inject private NotificationsPopupPanel notifications; + @Inject private Menu menu; + + @InjectTestWorkspace(template = WorkspaceTemplate.CODENVY_UBUNTU_JDK8) + private TestWorkspace ws; + + @Inject private Ide ide; + @Inject private Consoles consoles; + @Inject private CodenvyEditor editor; + @Inject private TestCommandServiceClient testCommandServiceClient; + @Inject private CommandsPalette commandsPalette; + @Inject private TestProjectServiceClient projectServiceClient; + + @BeforeClass + public void prepareTestProject() throws Exception { + + CompileCommand compileCommand = new CompileCommand(); + testCommandServiceClient.createCommand(DtoConverter.asDto(compileCommand), ws.getName()); + projectServiceClient.importProject( + ws.getId(), + Paths.get( + getClass() + .getResource("projects/plugins/JavaTestRunnerPlugin/" + JUNIT4_PROJECT) + .toURI()), + JUNIT4_PROJECT, + ProjectTemplates.CONSOLE_JAVA_SIMPLE); + ide.open(ws); + loader.waitOnClosed(); + projectExplorer.waitItem(JUNIT4_PROJECT); + runCompileCommandByPallete(compileCommand); + notifications.waitProgressPopupPanelClose(); + consoles.drugConsolesInDefinePosition(-100); + } + + @Test + public void shouldExecuteJUnit4TestClassWithDifferentStatuses() throws InterruptedException { + // given + String expectedResultAfterFirstLaunch = + "Default Suite\n" + + "org.eclipse.che.tests.AppOneTest\n" + + "shouldBeIgnoredOfAppOne\n" + + "shouldSuccessOfAppOne\n" + + "shouldFailOfAppOne\n" + + "org.eclipse.che.suite.Junit4TestSuite\n" + + "org.eclipse.che.tests.AppAnotherTest\n" + + "shouldFailOfAppAnother\n" + + "shouldSuccessOfAppAnother\n" + + "org.eclipse.che.tests.AppAnotherTest\n" + + "shouldFailOfAppAnother\n" + + "shouldSuccessOfAppAnother\n" + + "org.eclipse.che.tests.AppAnotherTest\n" + + "shouldFailOfAppAnother\n" + + "shouldSuccessOfAppAnother"; + + String expectedResultAfterSecondLaunch = + "Default Suite\n" + + "org.eclipse.che.tests.AppOneTest\n" + + "shouldBeIgnoredOfAppOne\n" + + "shouldSuccessOfAppOne\n" + + "shouldFailOfAppOne\n" + + "org.eclipse.che.tests.AppAnotherTest\n" + + "shouldFailOfAppAnother\n" + + "shouldSuccessOfAppAnother"; + + projectExplorer.quickRevealToItemWithJavaScript(PATH_TO_JUNIT4_TEST_CLASSES); + projectExplorer.openItemByPath(PATH_TO_JUNIT4_TEST_CLASSES); + projectExplorer.selectItem(JUNIT4_PROJECT); + // when + menu.runCommand(TestMenuCommandsConstants.Run.RUN_MENU, (TestMenuCommandsConstants.Run.TEST, (TestMenuCommandsConstants.Run.R); + + // then + notifications.waitExpectedMessageOnProgressPanelAndClosed("Test runner executed successfully."); + pluginConsole.waitFqnOfTesClassInResultTree("org.eclipse.che.tests.AppAnotherTest"); + assertTrue(pluginConsole.getTextFromResultTree().equals(expectedResultAfterFirstLaunch)); + pluginConsole.waitFqnOfTesClassInResultTree("org.eclipse.che.tests.AppOneTest"); + pluginConsole.waitMethodMarkedAsPassed("shouldSuccessOfAppOne"); + pluginConsole.waitMethodMarkedAsFailed("shouldFailOfAppOne"); + pluginConsole.waitMethodMarkedAsIgnored("shouldBeIgnoredOfAppOne"); + pluginConsole.selectItemInResultTree("shouldFailOfAppAnother"); + String testOutput = pluginConsole.getVisibleTextFromCommandConsole(); + } + + private void runCompileCommandByPallete(CompileCommand compileCommand) { + commandsPalette.openCommandPalette(); + commandsPalette.startCommandByDoubleClick(compileCommand.getName()); + consoles.waitExpectedTextIntoConsole(TestConstants.BuildMessages.BUILD_SUCCESS); + } +} diff --git a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/testrunner/JavaTestPluginJunit4Test.java b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/testrunner/JavaTestPluginJunit4Test.java index 641bb300bc4..2d793024c02 100644 --- a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/testrunner/JavaTestPluginJunit4Test.java +++ b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/testrunner/JavaTestPluginJunit4Test.java @@ -19,7 +19,6 @@ import static org.testng.Assert.assertTrue; import com.google.inject.Inject; -import java.net.URL; import java.nio.file.Paths; import org.eclipse.che.api.workspace.server.DtoConverter; import org.eclipse.che.selenium.core.client.TestCommandServiceClient; @@ -38,6 +37,7 @@ import org.eclipse.che.selenium.pageobject.ProjectExplorer; import org.eclipse.che.selenium.pageobject.intelligent.CommandsPalette; import org.eclipse.che.selenium.pageobject.plugins.JavaTestRunnerPluginConsole; +import org.testng.Assert; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -79,19 +79,20 @@ public class JavaTestPluginJunit4Test { @Inject private Ide ide; @Inject private Consoles consoles; @Inject private CodenvyEditor editor; - @Inject private TestProjectServiceClient testProjectServiceClient; @Inject private TestCommandServiceClient testCommandServiceClient; @Inject private CommandsPalette commandsPalette; + @Inject private TestProjectServiceClient projectServiceClient; @BeforeClass public void prepareTestProject() throws Exception { CompileCommand compileCommand = new CompileCommand(); testCommandServiceClient.createCommand(DtoConverter.asDto(compileCommand), ws.getId()); - - URL resource = getClass().getResource("/projects/plugins/JavaTestRunnerPlugin/junit4-tests"); - testProjectServiceClient.importProject( + projectServiceClient.importProject( ws.getId(), - Paths.get(resource.toURI()), + Paths.get( + getClass() + .getResource("projects/plugins/JavaTestRunnerPlugin/" + JUNIT4_PROJECT) + .toURI()), JUNIT4_PROJECT, ProjectTemplates.CONSOLE_JAVA_SIMPLE); @@ -124,9 +125,9 @@ public void shouldExecuteJUnit4TestClassWithDifferentStatuses() throws Interrupt pluginConsole.waitMethodMarkedAsPassed("shouldSuccessOfAppOne"); pluginConsole.waitMethodMarkedAsFailed("shouldFailOfAppOne"); pluginConsole.waitMethodMarkedAsIgnored("shouldBeIgnoredOfAppOne"); - assertTrue(pluginConsole.getAllMethodsMarkedDefinedStatus(PASSED).size() == 1); - assertTrue(pluginConsole.getAllMethodsMarkedDefinedStatus(FAILED).size() == 1); - assertTrue(pluginConsole.getAllMethodsMarkedDefinedStatus(IGNORED).size() == 1); + Assert.assertTrue(pluginConsole.getAllMethodsMarkedDefinedStatus(PASSED).size() == 1); + Assert.assertTrue(pluginConsole.getAllMethodsMarkedDefinedStatus(FAILED).size() == 1); + Assert.assertTrue(pluginConsole.getAllMethodsMarkedDefinedStatus(IGNORED).size() == 1); String testErrorMessage = pluginConsole.getTestErrorMessage(); assertTrue( testErrorMessage.startsWith(APP_TEST_ONE_FAIL_OUTPUT_TEMPLATE), @@ -139,7 +140,11 @@ public void shouldExecuteJUnit4MethodWithDifferentStatuses() throws InterruptedE projectExplorer.quickRevealToItemWithJavaScript(PATH_TO_JUNIT4_ANOTHER_TEST); projectExplorer.openItemByPath(PATH_TO_JUNIT4_ANOTHER_TEST); editor.waitActiveEditor(); - editor.setCursorToDefinedLineAndChar(28, 17); + + //TODO should be removed after fix issue https://github.com/eclipse/che/issues/5875 + editor.selectTabByName("AppAnotherTest"); + + editor.setCursorToDefinedLineAndChar(27, 17); // when menu.runCommand(RUN_MENU, TEST, JUNIT_TEST); @@ -148,25 +153,29 @@ public void shouldExecuteJUnit4MethodWithDifferentStatuses() throws InterruptedE // then pluginConsole.waitFqnOfTesClassInResultTree("org.eclipse.che.examples.AppAnotherTest"); pluginConsole.waitMethodMarkedAsPassed("shouldSuccessOfAppAnother"); - assertTrue(pluginConsole.getAllMethodsMarkedDefinedStatus(PASSED).size() == 1); + Assert.assertTrue(pluginConsole.getAllMethodsMarkedDefinedStatus(PASSED).size() == 1); // then - editor.setCursorToDefinedLineAndChar(33, 17); + + //TODO should be removed after fix issue https://github.com/eclipse/che/issues/5875 + editor.selectTabByName("AppAnotherTest"); + + editor.setCursorToDefinedLineAndChar(32, 17); menu.runCommand(RUN_MENU, TEST, JUNIT_TEST); notifications.waitExpectedMessageOnProgressPanelAndClosed("Test runner executed successfully."); pluginConsole.waitMethodMarkedAsFailed("shouldFailOfAppAnother"); - assertTrue(pluginConsole.getAllMethodsMarkedDefinedStatus(FAILED).size() == 1); + Assert.assertTrue(pluginConsole.getAllMethodsMarkedDefinedStatus(FAILED).size() == 1); String testErrorMessage = pluginConsole.getTestErrorMessage(); assertTrue( testErrorMessage.startsWith(APP_TEST_ANOTHER_FAIL_OUTPUT_TEMPLATE), "Actual message was: " + testErrorMessage); - editor.setCursorToDefinedLineAndChar(39, 17); + //TODO should be removed after fix issue https://github.com/eclipse/che/issues/5875 + editor.selectTabByName("AppAnotherTest"); + + editor.setCursorToDefinedLineAndChar(38, 17); menu.runCommand(RUN_MENU, TEST, JUNIT_TEST); notifications.waitExpectedMessageOnProgressPanelAndClosed("Test runner executed successfully."); pluginConsole.waitMethodMarkedAsIgnored("shouldBeIgnoredOfAppAnother"); - assertTrue(pluginConsole.getAllMethodsMarkedDefinedStatus(IGNORED).size() == 1); - assertTrue( - testErrorMessage.startsWith(APP_TEST_ANOTHER_FAIL_OUTPUT_TEMPLATE), - "Actual message was: " + testErrorMessage); + Assert.assertTrue(pluginConsole.getAllMethodsMarkedDefinedStatus(IGNORED).size() == 1); } } diff --git a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/testrunner/JavaTestPluginTestNgTest.java b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/testrunner/JavaTestPluginTestNgTest.java index d0c8db280e1..98f69c0c368 100644 --- a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/testrunner/JavaTestPluginTestNgTest.java +++ b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/testrunner/JavaTestPluginTestNgTest.java @@ -38,6 +38,7 @@ import org.eclipse.che.selenium.pageobject.ProjectExplorer; import org.eclipse.che.selenium.pageobject.intelligent.CommandsPalette; import org.eclipse.che.selenium.pageobject.plugins.JavaTestRunnerPluginConsole; +import org.testng.Assert; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -81,7 +82,6 @@ public class JavaTestPluginTestNgTest { @Inject private Ide ide; @Inject private DefaultTestUser user; - @Inject private JavaTestRunnerPluginConsole pluginConsole; @Inject private ProjectExplorer projectExplorer; @Inject private Loader loader; @@ -123,8 +123,8 @@ public void shouldExecuteTestClassSuccessfully() throws InterruptedException { notifications.waitExpectedMessageOnProgressPanelAndClosed("Test runner executed successfully."); pluginConsole.waitMethodMarkedAsPassed("shouldSuccessOfAppOne"); pluginConsole.waitMethodMarkedAsFailed("shouldFailOfAppOne"); - assertTrue(pluginConsole.getAllMethodsMarkedDefinedStatus(PASSED).size() == 1); - assertTrue(pluginConsole.getAllMethodsMarkedDefinedStatus(FAILED).size() == 1); + Assert.assertTrue(pluginConsole.getAllMethodsMarkedDefinedStatus(PASSED).size() == 1); + Assert.assertTrue(pluginConsole.getAllMethodsMarkedDefinedStatus(FAILED).size() == 1); String testErrorMessage = pluginConsole.getTestErrorMessage(); assertTrue( testErrorMessage.startsWith(APP_TEST_ONE_FAIL_OUTPUT_TEMPLATE), @@ -142,11 +142,35 @@ public void shouldExecuteTestMethodsSuccessfully() throws InterruptedException { menu.runCommand(RUN_MENU, TEST, TEST_NG_TEST); notifications.waitExpectedMessageOnProgressPanelAndClosed("Test runner executed successfully."); pluginConsole.waitMethodMarkedAsPassed("shouldSuccessOfAppAnother"); - assertTrue(pluginConsole.getAllMethodsMarkedDefinedStatus(PASSED).size() == 1); + Assert.assertTrue(pluginConsole.getAllMethodsMarkedDefinedStatus(PASSED).size() == 1); + editor.setCursorToDefinedLineAndChar(30, 17); + menu.runCommand(RUN_MENU, TEST, TEST_NG_TEST); + pluginConsole.waitMethodMarkedAsFailed("shouldFailOfAppAnother"); + Assert.assertTrue(pluginConsole.getAllMethodsMarkedDefinedStatus(FAILED).size() == 1); + String testErrorMessage = pluginConsole.getTestErrorMessage(); + assertTrue( + testErrorMessage.startsWith(APP_TEST_ANOTHER_FAIL_OUTPUT_TEMPLATE), + "Actual message was: " + testErrorMessage); + assertTrue( + testErrorMessage.endsWith(END_OF_FAILED_TEST), "Actual message was: " + testErrorMessage); + } + + @Test(priority = 1) + public void shouldExecuteAlltets() throws InterruptedException { + // given + projectExplorer.openItemByPath(PATH_TO_ANOTHER_TEST_CLASS); + + // then + editor.waitActiveEditor(); + editor.setCursorToDefinedLineAndChar(25, 17); + menu.runCommand(RUN_MENU, TEST, TEST_NG_TEST); + notifications.waitExpectedMessageOnProgressPanelAndClosed("Test runner executed successfully."); + pluginConsole.waitMethodMarkedAsPassed("shouldSuccessOfAppAnother"); + Assert.assertTrue(pluginConsole.getAllMethodsMarkedDefinedStatus(PASSED).size() == 1); editor.setCursorToDefinedLineAndChar(30, 17); menu.runCommand(RUN_MENU, TEST, TEST_NG_TEST); pluginConsole.waitMethodMarkedAsFailed("shouldFailOfAppAnother"); - assertTrue(pluginConsole.getAllMethodsMarkedDefinedStatus(FAILED).size() == 1); + Assert.assertTrue(pluginConsole.getAllMethodsMarkedDefinedStatus(FAILED).size() == 1); String testErrorMessage = pluginConsole.getTestErrorMessage(); assertTrue( testErrorMessage.startsWith(APP_TEST_ANOTHER_FAIL_OUTPUT_TEMPLATE), From 7151deb137c2ce4ce8948cd5af5e22faf4e3d496 Mon Sep 17 00:00:00 2001 From: Maxim Musienko Date: Wed, 20 Sep 2017 10:06:08 +0300 Subject: [PATCH 2/9] add new test for checking new junit plugin --- .../JavaTestPluginJuinit4CheckRunSuitesAndScopesTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/testrunner/JavaTestPluginJuinit4CheckRunSuitesAndScopesTest.java b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/testrunner/JavaTestPluginJuinit4CheckRunSuitesAndScopesTest.java index e7d2cd5fdb4..a1a4ece19de 100644 --- a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/testrunner/JavaTestPluginJuinit4CheckRunSuitesAndScopesTest.java +++ b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/testrunner/JavaTestPluginJuinit4CheckRunSuitesAndScopesTest.java @@ -103,7 +103,7 @@ public void shouldExecuteJUnit4TestClassWithDifferentStatuses() throws Interrupt + "org.eclipse.che.tests.AppAnotherTest\n" + "shouldFailOfAppAnother\n" + "shouldSuccessOfAppAnother"; - + CheckFactoryWithSincePolicyTest String expectedResultAfterSecondLaunch = "Default Suite\n" + "org.eclipse.che.tests.AppOneTest\n" From 5e7c227c3092b51523d595fdef01e163a03011ce Mon Sep 17 00:00:00 2001 From: Maxim Musienko Date: Fri, 22 Sep 2017 09:52:12 +0300 Subject: [PATCH 3/9] add final steps in the tests --- .../constant/TestMenuCommandsConstants.java | 15 ++-- .../selenium/pageobject/CodenvyEditor.java | 16 ++++ .../che/selenium/pageobject/Consoles.java | 3 +- .../plugins/JavaTestRunnerPluginConsole.java | 73 ++++++++++++++++++- ...ginJuinit4CheckRunSuitesAndScopesTest.java | 50 +++++-------- .../testrunner/JavaTestPluginJunit4Test.java | 52 +++++-------- .../testrunner/JavaTestPluginTestNgTest.java | 31 ++++---- .../pom.xml | 48 ++++++++++++ .../java/org/eclipse/che/example/Hello.java | 25 +++++++ .../org/eclipse/che/example/HelloWorld.java | 22 ++++++ .../eclipse/che/suite/Junit4TestSuite.java | 23 ++++++ .../org/eclipse/che/tests/AppAnotherTest.java | 33 +++++++++ .../org/eclipse/che/tests/AppOneTest.java | 39 ++++++++++ 13 files changed, 340 insertions(+), 90 deletions(-) create mode 100644 selenium/che-selenium-test/src/test/resources/projects/plugins/JavaTestRunnerPlugin/junit4-tests-with-separeted-suites/pom.xml create mode 100644 selenium/che-selenium-test/src/test/resources/projects/plugins/JavaTestRunnerPlugin/junit4-tests-with-separeted-suites/src/main/java/org/eclipse/che/example/Hello.java create mode 100644 selenium/che-selenium-test/src/test/resources/projects/plugins/JavaTestRunnerPlugin/junit4-tests-with-separeted-suites/src/main/java/org/eclipse/che/example/HelloWorld.java create mode 100644 selenium/che-selenium-test/src/test/resources/projects/plugins/JavaTestRunnerPlugin/junit4-tests-with-separeted-suites/src/test/java/org/eclipse/che/suite/Junit4TestSuite.java create mode 100644 selenium/che-selenium-test/src/test/resources/projects/plugins/JavaTestRunnerPlugin/junit4-tests-with-separeted-suites/src/test/java/org/eclipse/che/tests/AppAnotherTest.java create mode 100644 selenium/che-selenium-test/src/test/resources/projects/plugins/JavaTestRunnerPlugin/junit4-tests-with-separeted-suites/src/test/java/org/eclipse/che/tests/AppOneTest.java diff --git a/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/core/constant/TestMenuCommandsConstants.java b/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/core/constant/TestMenuCommandsConstants.java index 6c9b6c9c4a9..a3a264d5771 100644 --- a/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/core/constant/TestMenuCommandsConstants.java +++ b/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/core/constant/TestMenuCommandsConstants.java @@ -101,15 +101,6 @@ interface Run { String DEBUG_CONFIGURATION = "gwt-debug-topmenu/Run/Debug Configurations"; String END_DEBUG_SESSION = "gwt-debug-topmenu/Run/disconnectDebug"; String TEST = "gwt-debug-topmenu/Run/TestingMainGroup"; - - interface Test { - String TEST_NG_TEST = "topmenu/Run/Test/Run Test"; - String TEST_NG_CLASS = "gwt-debug-topmenu/Run/Test/TestNGActionRunClass"; - String TEST_NG_PROJECT = "gwt-debug-topmenu/Run/Test/TestNGActionRunAllContext"; - String TEST_NG_XML_SUITE = "gwt-debug-topmenu/Run/Test/TestNGActionRunXMLContext"; - String JUNIT_TEST = "gwt-debug-topmenu/Run/Test/RunTest"; - String JUNIT_PROJECT = "gwt-debug-topmenu/Run/Test/TestJUnitActionRunAllContext"; - } } interface Profile { @@ -198,4 +189,10 @@ interface CommandList { String ITEM_PREFFIX_ID = "gwt-debug-CommandsGroup/"; String COMMAND_LIST_XPATH = "//div[@id='gwt-debug-dropDownHeader'][2]"; } + + public static final String TEST_NG_TEST_DROP_DAWN_ITEM = "topmenu/Run/Test/Run Test"; + public static final String JUNIT_TEST_DROP_DAWN_ITEM = + "gwt-debug-topmenu/Run/Test/TestJUnitActionRun"; + + public static final String TEST_DROP_DAWN_ITEM = "gwt-debug-topmenu/Run/Test/RunTest"; } diff --git a/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/pageobject/CodenvyEditor.java b/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/pageobject/CodenvyEditor.java index 2fb59c38c27..a7714252107 100644 --- a/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/pageobject/CodenvyEditor.java +++ b/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/pageobject/CodenvyEditor.java @@ -38,6 +38,7 @@ import java.util.stream.Collectors; import org.eclipse.che.selenium.core.SeleniumWebDriver; import org.eclipse.che.selenium.core.action.ActionsFactory; +import org.eclipse.che.selenium.core.constant.TestMenuCommandsConstants; import org.eclipse.che.selenium.core.utils.WaitUtils; import org.openqa.selenium.By; import org.openqa.selenium.Keys; @@ -60,6 +61,8 @@ public class CodenvyEditor { public static final String CLOSE_ALL_TABS = "gwt-debug-contextMenu/closeAllEditors"; + @Inject private Menu menu; + public static final class EditorContextMenu { public static final String REFACTORING = "contextMenu/Refactoring"; public static final String REFACTORING_MOVE = "contextMenu/Refactoring/Move"; @@ -511,6 +514,19 @@ public void setCursorToDefinedLineAndChar(int positionLine, int positionChar) { waitSpecifiedValueForLineAndChar(positionLine, positionChar); } + public void setCursorToDefinedLineAndCharByMenu() { + menu.runCommand( + TestMenuCommandsConstants.Run.RUN_MENU, TestMenuCommandsConstants.Run.DEBUG_CONFIGURATION); + } + + /** + * set cursor in specified position + * + * @param positionLine is the specified number line + * @param positionChar is the specified number char + */ + public void setCursorToDefinedLineAndCharByMenu(int positionLine, int positionChar) {} + /** launch code assistant with ctrl+space keys and wait container is open */ public void launchAutocompleteAndWaitContainer() { loader.waitOnClosed(); diff --git a/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/pageobject/Consoles.java b/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/pageobject/Consoles.java index f009b5a95f9..5f36b6e344f 100644 --- a/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/pageobject/Consoles.java +++ b/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/pageobject/Consoles.java @@ -73,6 +73,7 @@ public Consoles(SeleniumWebDriver seleniumWebDriver, Loader loader) { updateProjDriverWait = new WebDriverWait(seleniumWebDriver, UPDATING_PROJECT_TIMEOUT_SEC); PageFactory.initElements(seleniumWebDriver, this); } + @FindBy(css = CONSOLE_PANEL_DRUGGER_CSS) WebElement consolesPanelDrugger; @@ -311,7 +312,7 @@ public void clickOnMaximizePanelIcon() { */ public void drugConsolesInDefinePosition(int xoffset) { WebElement drugger = - redrawDriverWait.until(ExpectedConditions.visibilityOf(consolesPanelDrugger)); + redrawDriverWait.until(ExpectedConditions.visibilityOf(consolesPanelDrugger)); new Actions(seleniumWebDriver).dragAndDropBy(drugger, xoffset, xoffset).perform(); } } diff --git a/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/pageobject/plugins/JavaTestRunnerPluginConsole.java b/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/pageobject/plugins/JavaTestRunnerPluginConsole.java index 825dcab0ae9..0b72b149fa9 100644 --- a/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/pageobject/plugins/JavaTestRunnerPluginConsole.java +++ b/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/pageobject/plugins/JavaTestRunnerPluginConsole.java @@ -16,6 +16,7 @@ import com.google.inject.Inject; import com.google.inject.Singleton; import java.util.List; +import java.util.Objects; import java.util.stream.Collectors; import org.eclipse.che.selenium.core.SeleniumWebDriver; import org.eclipse.che.selenium.pageobject.Consoles; @@ -42,6 +43,9 @@ public class JavaTestRunnerPluginConsole extends Consoles { "//div[contains(@id,'gwt-uid')]//div[@style='color: red;']"; private static final String METHODS_MARKED_AS_IGNORED = "//div[contains(@id,'gwt-uid')]//div[@style='text-decoration: line-through; color: yellow;']"; + private static final String TEST_RESULT_TREE_ITEM = "gwt-debug-test-tree-navigation-panel"; + + private static final String TEST_RESULT_NAVIGATION_TREE = "gwt-debug-test-tree-navigation-panel"; @FindAll({@FindBy(xpath = TEST_OUTPUT_XPATH)}) private List testOutput; @@ -64,6 +68,9 @@ public class JavaTestRunnerPluginConsole extends Consoles { @FindAll({@FindBy(xpath = METHODS_MARKED_AS_IGNORED)}) private List ignoredMethods; + @FindBy(id = TEST_RESULT_NAVIGATION_TREE) + private WebElement resultTreeMainForm; + @Inject public JavaTestRunnerPluginConsole(SeleniumWebDriver seleniumWebDriver, Loader loader) { super(seleniumWebDriver, loader); @@ -123,7 +130,7 @@ public void waitMethodMarkedAsPassed(String nameOfFailedMethods) { public void waitFqnOfTesClassInResultTree(String fqn) { new WebDriverWait(seleniumWebDriver, MINIMUM_SEC) .until( - ExpectedConditions.visibilityOfAllElementsLocatedBy( + ExpectedConditions.visibilityOfElementLocated( By.xpath(String.format(TEST_RESULT_TREE_XPATH_TEMPLATE, fqn)))); } @@ -134,7 +141,7 @@ public void waitFqnOfTesClassInResultTree(String fqn) { * @param methodState the enumeration with defined status * @return the list with names of methods with defined status */ - public List getAllMethodsMarkedDefinedStatus(JunitMethodsState methodState) { + public List getAllNamesOfMethodsMarkedDefinedStatus(JunitMethodsState methodState) { List definedMethods = null; switch (methodState) { case PASSED: @@ -150,6 +157,28 @@ public List getAllMethodsMarkedDefinedStatus(JunitMethodsState methodSta return definedMethods; } + /** + * get all defined methods from result tree and return as list WebElements + * + * @param methodState the enumeration with defined status + * @return List WebElements with defined status + */ + public List getAllMethodsMarkedDefinedStatus(JunitMethodsState methodState) { + List definedMethods = null; + switch (methodState) { + case PASSED: + definedMethods = passedMethods; + break; + case FAILED: + definedMethods = failedMethods; + break; + case IGNORED: + definedMethods = ignoredMethods; + break; + } + return definedMethods; + } + private List getAllMetodsWithDefinedStatus(List definedMethod) { return new WebDriverWait(seleniumWebDriver, MINIMUM_SEC) .until(ExpectedConditions.visibilityOfAllElements(definedMethod)) @@ -157,4 +186,44 @@ private List getAllMetodsWithDefinedStatus(List definedMetho .map(WebElement::getText) .collect(Collectors.toList()); } + + /** + * get taxt from the test result tree. Mote! This method represent only text from test result tree + * without styles and formatting + * + * @return text representation of results of the test result tree widget + */ + public String getTextFromResultTree() { + return new WebDriverWait(seleniumWebDriver, REDRAW_UI_ELEMENTS_TIMEOUT_SEC) + .until(ExpectedConditions.visibilityOf(resultTreeMainForm)) + .getText(); + } + + /** + * click on the item in the result tree. If will be some items with the same name - will select + * first + * + * @param item name of the item (method or fqn of test class) in the test result tree + */ + public void selectItemInResultTree(String item) { + new WebDriverWait(seleniumWebDriver, MINIMUM_SEC) + .until(ExpectedConditions.visibilityOf(resultTreeMainForm)) + .findElement(By.xpath(String.format("//div[text()='%s']", item))) + .click(); + } + + /** + * click on faled, passed or ignored method on the result tree + * + * @param nameOfMethod + * @param state + */ + public void selectMethodWithDefinedStatus(JunitMethodsState state, String nameOfMethod) { + getAllMethodsMarkedDefinedStatus(state) + .stream() + .filter(webElement -> Objects.equals(webElement.getText(), nameOfMethod)) + .findFirst() + .get() + .click(); + } } diff --git a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/testrunner/JavaTestPluginJuinit4CheckRunSuitesAndScopesTest.java b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/testrunner/JavaTestPluginJuinit4CheckRunSuitesAndScopesTest.java index a1a4ece19de..04580a41b5d 100644 --- a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/testrunner/JavaTestPluginJuinit4CheckRunSuitesAndScopesTest.java +++ b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/testrunner/JavaTestPluginJuinit4CheckRunSuitesAndScopesTest.java @@ -10,16 +10,18 @@ */ package org.eclipse.che.selenium.testrunner; -import com.google.inject.Inject; +import static org.eclipse.che.selenium.pageobject.plugins.JavaTestRunnerPluginConsole.JunitMethodsState.FAILED; +import static org.testng.Assert.assertTrue; +import com.google.inject.Inject; +import java.nio.file.Paths; import org.eclipse.che.api.workspace.server.DtoConverter; import org.eclipse.che.selenium.core.client.TestCommandServiceClient; import org.eclipse.che.selenium.core.client.TestProjectServiceClient; +import org.eclipse.che.selenium.core.constant.TestBuildConstants; import org.eclipse.che.selenium.core.constant.TestMenuCommandsConstants; import org.eclipse.che.selenium.core.project.ProjectTemplates; -import org.eclipse.che.selenium.core.workspace.InjectTestWorkspace; import org.eclipse.che.selenium.core.workspace.TestWorkspace; -import org.eclipse.che.selenium.core.workspace.WorkspaceTemplate; import org.eclipse.che.selenium.pageobject.CodenvyEditor; import org.eclipse.che.selenium.pageobject.Consoles; import org.eclipse.che.selenium.pageobject.Ide; @@ -32,13 +34,6 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import java.nio.file.Paths; - - - - -import static org.testng.Assert.assertTrue; - public class JavaTestPluginJuinit4CheckRunSuitesAndScopesTest { private static final String JUNIT4_PROJECT = "junit4-tests-with-separeted-suites"; @@ -53,8 +48,7 @@ public class JavaTestPluginJuinit4CheckRunSuitesAndScopesTest { @Inject private NotificationsPopupPanel notifications; @Inject private Menu menu; - @InjectTestWorkspace(template = WorkspaceTemplate.CODENVY_UBUNTU_JDK8) - private TestWorkspace ws; + @Inject private TestWorkspace ws; @Inject private Ide ide; @Inject private Consoles consoles; @@ -65,14 +59,13 @@ public class JavaTestPluginJuinit4CheckRunSuitesAndScopesTest { @BeforeClass public void prepareTestProject() throws Exception { - CompileCommand compileCommand = new CompileCommand(); - testCommandServiceClient.createCommand(DtoConverter.asDto(compileCommand), ws.getName()); + testCommandServiceClient.createCommand(DtoConverter.asDto(compileCommand), ws.getId()); projectServiceClient.importProject( ws.getId(), Paths.get( getClass() - .getResource("projects/plugins/JavaTestRunnerPlugin/" + JUNIT4_PROJECT) + .getResource("/projects/plugins/JavaTestRunnerPlugin/" + JUNIT4_PROJECT) .toURI()), JUNIT4_PROJECT, ProjectTemplates.CONSOLE_JAVA_SIMPLE); @@ -103,22 +96,19 @@ public void shouldExecuteJUnit4TestClassWithDifferentStatuses() throws Interrupt + "org.eclipse.che.tests.AppAnotherTest\n" + "shouldFailOfAppAnother\n" + "shouldSuccessOfAppAnother"; - CheckFactoryWithSincePolicyTest - String expectedResultAfterSecondLaunch = - "Default Suite\n" - + "org.eclipse.che.tests.AppOneTest\n" - + "shouldBeIgnoredOfAppOne\n" - + "shouldSuccessOfAppOne\n" - + "shouldFailOfAppOne\n" - + "org.eclipse.che.tests.AppAnotherTest\n" - + "shouldFailOfAppAnother\n" - + "shouldSuccessOfAppAnother"; + + String expectedExceptionForFailedTest = + "java.lang.AssertionError\n" + + " at org.junit.Assert.fail(Assert.java:86)\n" + + " at org.junit.Assert.assertTrue(Assert.java:41)"; projectExplorer.quickRevealToItemWithJavaScript(PATH_TO_JUNIT4_TEST_CLASSES); - projectExplorer.openItemByPath(PATH_TO_JUNIT4_TEST_CLASSES); projectExplorer.selectItem(JUNIT4_PROJECT); // when - menu.runCommand(TestMenuCommandsConstants.Run.RUN_MENU, (TestMenuCommandsConstants.Run.TEST, (TestMenuCommandsConstants.Run.R); + menu.runCommand( + TestMenuCommandsConstants.Run.RUN_MENU, + TestMenuCommandsConstants.Run.TEST, + TestMenuCommandsConstants.JUNIT_TEST_DROP_DAWN_ITEM); // then notifications.waitExpectedMessageOnProgressPanelAndClosed("Test runner executed successfully."); @@ -128,13 +118,13 @@ public void shouldExecuteJUnit4TestClassWithDifferentStatuses() throws Interrupt pluginConsole.waitMethodMarkedAsPassed("shouldSuccessOfAppOne"); pluginConsole.waitMethodMarkedAsFailed("shouldFailOfAppOne"); pluginConsole.waitMethodMarkedAsIgnored("shouldBeIgnoredOfAppOne"); - pluginConsole.selectItemInResultTree("shouldFailOfAppAnother"); - String testOutput = pluginConsole.getVisibleTextFromCommandConsole(); + pluginConsole.selectMethodWithDefinedStatus(FAILED, "shouldFailOfAppAnother"); + assertTrue(pluginConsole.getTestErrorMessage().startsWith(expectedExceptionForFailedTest)); } private void runCompileCommandByPallete(CompileCommand compileCommand) { commandsPalette.openCommandPalette(); commandsPalette.startCommandByDoubleClick(compileCommand.getName()); - consoles.waitExpectedTextIntoConsole(TestConstants.BuildMessages.BUILD_SUCCESS); + consoles.waitExpectedTextIntoConsole(TestBuildConstants.BUILD_SUCCESS); } } diff --git a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/testrunner/JavaTestPluginJunit4Test.java b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/testrunner/JavaTestPluginJunit4Test.java index 2d793024c02..240558d7087 100644 --- a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/testrunner/JavaTestPluginJunit4Test.java +++ b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/testrunner/JavaTestPluginJunit4Test.java @@ -12,7 +12,7 @@ import static org.eclipse.che.selenium.core.constant.TestMenuCommandsConstants.Run.RUN_MENU; import static org.eclipse.che.selenium.core.constant.TestMenuCommandsConstants.Run.TEST; -import static org.eclipse.che.selenium.core.constant.TestMenuCommandsConstants.Run.Test.JUNIT_TEST; +import static org.eclipse.che.selenium.core.constant.TestMenuCommandsConstants.TEST_DROP_DAWN_ITEM; import static org.eclipse.che.selenium.pageobject.plugins.JavaTestRunnerPluginConsole.JunitMethodsState.FAILED; import static org.eclipse.che.selenium.pageobject.plugins.JavaTestRunnerPluginConsole.JunitMethodsState.IGNORED; import static org.eclipse.che.selenium.pageobject.plugins.JavaTestRunnerPluginConsole.JunitMethodsState.PASSED; @@ -25,9 +25,7 @@ import org.eclipse.che.selenium.core.client.TestProjectServiceClient; import org.eclipse.che.selenium.core.constant.TestBuildConstants; import org.eclipse.che.selenium.core.project.ProjectTemplates; -import org.eclipse.che.selenium.core.workspace.InjectTestWorkspace; import org.eclipse.che.selenium.core.workspace.TestWorkspace; -import org.eclipse.che.selenium.core.workspace.WorkspaceTemplate; import org.eclipse.che.selenium.pageobject.CodenvyEditor; import org.eclipse.che.selenium.pageobject.Consoles; import org.eclipse.che.selenium.pageobject.Ide; @@ -48,7 +46,7 @@ public class JavaTestPluginJunit4Test { private static final String PATH_TO_JUNIT4_TEST_CLASS = JUNIT4_PROJECT + "/src/test/java/org/eclipse/che/examples/AppOneTest.java"; private static final String PATH_TO_JUNIT4_ANOTHER_TEST = - JUNIT4_PROJECT + "/src/test/java/org/eclipse/che/examples/AppAppAnotherTest.java"; + JUNIT4_PROJECT + "/src/test/java/org/eclipse/che/examples/AppAnotherTest.java"; private static final String PATH_TO_JUNIT4_TEST_SUITE = JUNIT4_PROJECT + "/src/test/java/org/eclipse/che/examples/Junit4TestSuite.java"; @@ -66,15 +64,15 @@ public class JavaTestPluginJunit4Test { + " at org.junit.Assert.assertTrue(Assert.java:41)\n" + " at org.junit.Assert.assertFalse(Assert.java:64)\n" + " at org.junit.Assert.assertFalse(Assert.java:74)\n" - + " at org.eclipse.che.examples.AppAnotherTest.shouldFailOfAppAnother(AppAnotherTest.java:33)"; + + " at org.eclipse.che.examples.AppAnotherTest.shouldFailOfAppAnother(AppAnotherTest.java:34)"; + @Inject private JavaTestRunnerPluginConsole pluginConsole; @Inject private ProjectExplorer projectExplorer; @Inject private Loader loader; @Inject private NotificationsPopupPanel notifications; @Inject private Menu menu; - @InjectTestWorkspace(template = WorkspaceTemplate.CODENVY_UBUNTU_JDK8) - private TestWorkspace ws; + @Inject private TestWorkspace ws; @Inject private Ide ide; @Inject private Consoles consoles; @@ -91,7 +89,7 @@ public void prepareTestProject() throws Exception { ws.getId(), Paths.get( getClass() - .getResource("projects/plugins/JavaTestRunnerPlugin/" + JUNIT4_PROJECT) + .getResource("/projects/plugins/JavaTestRunnerPlugin/" + JUNIT4_PROJECT) .toURI()), JUNIT4_PROJECT, ProjectTemplates.CONSOLE_JAVA_SIMPLE); @@ -99,6 +97,7 @@ public void prepareTestProject() throws Exception { ide.open(ws); loader.waitOnClosed(); projectExplorer.waitItem(JUNIT4_PROJECT); + projectExplorer.quickExpandWithJavaScript(); runCompileCommandByPallete(compileCommand); notifications.waitProgressPopupPanelClose(); } @@ -112,11 +111,10 @@ private void runCompileCommandByPallete(CompileCommand compileCommand) { @Test public void shouldExecuteJUnit4TestClassWithDifferentStatuses() throws InterruptedException { // given - projectExplorer.quickRevealToItemWithJavaScript(PATH_TO_JUNIT4_TEST_CLASS); projectExplorer.openItemByPath(PATH_TO_JUNIT4_TEST_CLASS); // when - menu.runCommand(RUN_MENU, TEST, JUNIT_TEST); + menu.runCommand(RUN_MENU, TEST, TEST_DROP_DAWN_ITEM); // then notifications.waitExpectedMessageOnProgressPanelAndClosed("Test runner executed successfully."); @@ -125,9 +123,9 @@ public void shouldExecuteJUnit4TestClassWithDifferentStatuses() throws Interrupt pluginConsole.waitMethodMarkedAsPassed("shouldSuccessOfAppOne"); pluginConsole.waitMethodMarkedAsFailed("shouldFailOfAppOne"); pluginConsole.waitMethodMarkedAsIgnored("shouldBeIgnoredOfAppOne"); - Assert.assertTrue(pluginConsole.getAllMethodsMarkedDefinedStatus(PASSED).size() == 1); - Assert.assertTrue(pluginConsole.getAllMethodsMarkedDefinedStatus(FAILED).size() == 1); - Assert.assertTrue(pluginConsole.getAllMethodsMarkedDefinedStatus(IGNORED).size() == 1); + Assert.assertTrue(pluginConsole.getAllNamesOfMethodsMarkedDefinedStatus(PASSED).size() == 1); + Assert.assertTrue(pluginConsole.getAllNamesOfMethodsMarkedDefinedStatus(FAILED).size() == 1); + Assert.assertTrue(pluginConsole.getAllNamesOfMethodsMarkedDefinedStatus(IGNORED).size() == 1); String testErrorMessage = pluginConsole.getTestErrorMessage(); assertTrue( testErrorMessage.startsWith(APP_TEST_ONE_FAIL_OUTPUT_TEMPLATE), @@ -137,45 +135,35 @@ public void shouldExecuteJUnit4TestClassWithDifferentStatuses() throws Interrupt @Test(priority = 1) public void shouldExecuteJUnit4MethodWithDifferentStatuses() throws InterruptedException { // given - projectExplorer.quickRevealToItemWithJavaScript(PATH_TO_JUNIT4_ANOTHER_TEST); projectExplorer.openItemByPath(PATH_TO_JUNIT4_ANOTHER_TEST); editor.waitActiveEditor(); - //TODO should be removed after fix issue https://github.com/eclipse/che/issues/5875 - editor.selectTabByName("AppAnotherTest"); - - editor.setCursorToDefinedLineAndChar(27, 17); + editor.setCursorToDefinedLineAndChar(27, 5); // when - menu.runCommand(RUN_MENU, TEST, JUNIT_TEST); + menu.runCommand(RUN_MENU, TEST, TEST_DROP_DAWN_ITEM); notifications.waitExpectedMessageOnProgressPanelAndClosed("Test runner executed successfully."); // then pluginConsole.waitFqnOfTesClassInResultTree("org.eclipse.che.examples.AppAnotherTest"); pluginConsole.waitMethodMarkedAsPassed("shouldSuccessOfAppAnother"); - Assert.assertTrue(pluginConsole.getAllMethodsMarkedDefinedStatus(PASSED).size() == 1); + Assert.assertTrue(pluginConsole.getAllNamesOfMethodsMarkedDefinedStatus(PASSED).size() == 1); // then - //TODO should be removed after fix issue https://github.com/eclipse/che/issues/5875 - editor.selectTabByName("AppAnotherTest"); - - editor.setCursorToDefinedLineAndChar(32, 17); - menu.runCommand(RUN_MENU, TEST, JUNIT_TEST); + editor.setCursorToDefinedLineAndChar(32, 5); + menu.runCommand(RUN_MENU, TEST, TEST_DROP_DAWN_ITEM); notifications.waitExpectedMessageOnProgressPanelAndClosed("Test runner executed successfully."); pluginConsole.waitMethodMarkedAsFailed("shouldFailOfAppAnother"); - Assert.assertTrue(pluginConsole.getAllMethodsMarkedDefinedStatus(FAILED).size() == 1); + Assert.assertTrue(pluginConsole.getAllNamesOfMethodsMarkedDefinedStatus(FAILED).size() == 1); String testErrorMessage = pluginConsole.getTestErrorMessage(); assertTrue( testErrorMessage.startsWith(APP_TEST_ANOTHER_FAIL_OUTPUT_TEMPLATE), "Actual message was: " + testErrorMessage); - //TODO should be removed after fix issue https://github.com/eclipse/che/issues/5875 - editor.selectTabByName("AppAnotherTest"); - - editor.setCursorToDefinedLineAndChar(38, 17); - menu.runCommand(RUN_MENU, TEST, JUNIT_TEST); + editor.setCursorToDefinedLineAndChar(38, 5); + menu.runCommand(RUN_MENU, TEST, TEST_DROP_DAWN_ITEM); notifications.waitExpectedMessageOnProgressPanelAndClosed("Test runner executed successfully."); pluginConsole.waitMethodMarkedAsIgnored("shouldBeIgnoredOfAppAnother"); - Assert.assertTrue(pluginConsole.getAllMethodsMarkedDefinedStatus(IGNORED).size() == 1); + Assert.assertTrue(pluginConsole.getAllNamesOfMethodsMarkedDefinedStatus(IGNORED).size() == 1); } } diff --git a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/testrunner/JavaTestPluginTestNgTest.java b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/testrunner/JavaTestPluginTestNgTest.java index 98f69c0c368..974241d7473 100644 --- a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/testrunner/JavaTestPluginTestNgTest.java +++ b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/testrunner/JavaTestPluginTestNgTest.java @@ -12,7 +12,7 @@ import static org.eclipse.che.selenium.core.constant.TestMenuCommandsConstants.Run.RUN_MENU; import static org.eclipse.che.selenium.core.constant.TestMenuCommandsConstants.Run.TEST; -import static org.eclipse.che.selenium.core.constant.TestMenuCommandsConstants.Run.Test.TEST_NG_TEST; +import static org.eclipse.che.selenium.core.constant.TestMenuCommandsConstants.TEST_NG_TEST_DROP_DAWN_ITEM; import static org.eclipse.che.selenium.pageobject.plugins.JavaTestRunnerPluginConsole.JunitMethodsState.FAILED; import static org.eclipse.che.selenium.pageobject.plugins.JavaTestRunnerPluginConsole.JunitMethodsState.PASSED; import static org.testng.Assert.assertTrue; @@ -71,11 +71,10 @@ public class JavaTestPluginTestNgTest { + " at org.testng.Assert.fail(Assert.java:94)\n" + " at org.testng.Assert.failNotEquals(Assert.java:494)\n" + " at org.testng.Assert.assertFalse(Assert.java:63)\n" - + " at org.testng.Assert.assertFalse(Assert.java:73)\n" - + " at org.eclipse.che.examples.AppAnotherTest.shouldFailOfAppAnother(AppAnotherTest.java:31)"; + + " at org.testng.Assert.assertFalse(Assert.java:73)"; public static final String END_OF_FAILED_TEST = - "at org.testng.CheTestNGLauncher.main(CheTestNGLauncher.java:43)===============================================Default SuiteTotal tests run: 1, Failures: 1, Skips: 0==============================================="; + "===============================================Default SuiteTotal tests run: 1, Failures: 1, Skips: 0==============================================="; @InjectTestWorkspace(template = WorkspaceTemplate.CODENVY_UBUNTU_JDK8) private TestWorkspace ws; @@ -117,14 +116,14 @@ public void shouldExecuteTestClassSuccessfully() throws InterruptedException { // when editor.waitActiveEditor(); - menu.runCommand(RUN_MENU, TEST, TEST_NG_TEST); + menu.runCommand(RUN_MENU, TEST, TEST_NG_TEST_DROP_DAWN_ITEM); // then notifications.waitExpectedMessageOnProgressPanelAndClosed("Test runner executed successfully."); pluginConsole.waitMethodMarkedAsPassed("shouldSuccessOfAppOne"); pluginConsole.waitMethodMarkedAsFailed("shouldFailOfAppOne"); - Assert.assertTrue(pluginConsole.getAllMethodsMarkedDefinedStatus(PASSED).size() == 1); - Assert.assertTrue(pluginConsole.getAllMethodsMarkedDefinedStatus(FAILED).size() == 1); + Assert.assertTrue(pluginConsole.getAllNamesOfMethodsMarkedDefinedStatus(PASSED).size() == 1); + Assert.assertTrue(pluginConsole.getAllNamesOfMethodsMarkedDefinedStatus(FAILED).size() == 1); String testErrorMessage = pluginConsole.getTestErrorMessage(); assertTrue( testErrorMessage.startsWith(APP_TEST_ONE_FAIL_OUTPUT_TEMPLATE), @@ -139,14 +138,14 @@ public void shouldExecuteTestMethodsSuccessfully() throws InterruptedException { // then editor.waitActiveEditor(); editor.setCursorToDefinedLineAndChar(25, 17); - menu.runCommand(RUN_MENU, TEST, TEST_NG_TEST); + menu.runCommand(RUN_MENU, TEST, TEST_NG_TEST_DROP_DAWN_ITEM); notifications.waitExpectedMessageOnProgressPanelAndClosed("Test runner executed successfully."); pluginConsole.waitMethodMarkedAsPassed("shouldSuccessOfAppAnother"); - Assert.assertTrue(pluginConsole.getAllMethodsMarkedDefinedStatus(PASSED).size() == 1); + Assert.assertTrue(pluginConsole.getAllNamesOfMethodsMarkedDefinedStatus(PASSED).size() == 1); editor.setCursorToDefinedLineAndChar(30, 17); - menu.runCommand(RUN_MENU, TEST, TEST_NG_TEST); + menu.runCommand(RUN_MENU, TEST, TEST_NG_TEST_DROP_DAWN_ITEM); pluginConsole.waitMethodMarkedAsFailed("shouldFailOfAppAnother"); - Assert.assertTrue(pluginConsole.getAllMethodsMarkedDefinedStatus(FAILED).size() == 1); + Assert.assertTrue(pluginConsole.getAllNamesOfMethodsMarkedDefinedStatus(FAILED).size() == 1); String testErrorMessage = pluginConsole.getTestErrorMessage(); assertTrue( testErrorMessage.startsWith(APP_TEST_ANOTHER_FAIL_OUTPUT_TEMPLATE), @@ -155,7 +154,7 @@ public void shouldExecuteTestMethodsSuccessfully() throws InterruptedException { testErrorMessage.endsWith(END_OF_FAILED_TEST), "Actual message was: " + testErrorMessage); } - @Test(priority = 1) + @Test(priority = 2) public void shouldExecuteAlltets() throws InterruptedException { // given projectExplorer.openItemByPath(PATH_TO_ANOTHER_TEST_CLASS); @@ -163,14 +162,14 @@ public void shouldExecuteAlltets() throws InterruptedException { // then editor.waitActiveEditor(); editor.setCursorToDefinedLineAndChar(25, 17); - menu.runCommand(RUN_MENU, TEST, TEST_NG_TEST); + menu.runCommand(RUN_MENU, TEST, TEST_NG_TEST_DROP_DAWN_ITEM); notifications.waitExpectedMessageOnProgressPanelAndClosed("Test runner executed successfully."); pluginConsole.waitMethodMarkedAsPassed("shouldSuccessOfAppAnother"); - Assert.assertTrue(pluginConsole.getAllMethodsMarkedDefinedStatus(PASSED).size() == 1); + Assert.assertTrue(pluginConsole.getAllNamesOfMethodsMarkedDefinedStatus(PASSED).size() == 1); editor.setCursorToDefinedLineAndChar(30, 17); - menu.runCommand(RUN_MENU, TEST, TEST_NG_TEST); + menu.runCommand(RUN_MENU, TEST, TEST_NG_TEST_DROP_DAWN_ITEM); pluginConsole.waitMethodMarkedAsFailed("shouldFailOfAppAnother"); - Assert.assertTrue(pluginConsole.getAllMethodsMarkedDefinedStatus(FAILED).size() == 1); + Assert.assertTrue(pluginConsole.getAllNamesOfMethodsMarkedDefinedStatus(FAILED).size() == 1); String testErrorMessage = pluginConsole.getTestErrorMessage(); assertTrue( testErrorMessage.startsWith(APP_TEST_ANOTHER_FAIL_OUTPUT_TEMPLATE), diff --git a/selenium/che-selenium-test/src/test/resources/projects/plugins/JavaTestRunnerPlugin/junit4-tests-with-separeted-suites/pom.xml b/selenium/che-selenium-test/src/test/resources/projects/plugins/JavaTestRunnerPlugin/junit4-tests-with-separeted-suites/pom.xml new file mode 100644 index 00000000000..fb16bf52422 --- /dev/null +++ b/selenium/che-selenium-test/src/test/resources/projects/plugins/JavaTestRunnerPlugin/junit4-tests-with-separeted-suites/pom.xml @@ -0,0 +1,48 @@ + + + 4.0.0 + org.eclipse.che.examples + console-java-simple + jar + 1.0-SNAPSHOT + hello-app + http://maven.apache.org + + + junit + junit + 4.12 + test + + + + + + org.apache.maven.plugins + maven-jar-plugin + 2.4 + + + + true + lib/ + org.eclipse.che.examples.HelloWorld + + + + + + + diff --git a/selenium/che-selenium-test/src/test/resources/projects/plugins/JavaTestRunnerPlugin/junit4-tests-with-separeted-suites/src/main/java/org/eclipse/che/example/Hello.java b/selenium/che-selenium-test/src/test/resources/projects/plugins/JavaTestRunnerPlugin/junit4-tests-with-separeted-suites/src/main/java/org/eclipse/che/example/Hello.java new file mode 100644 index 00000000000..c3d7f4def9b --- /dev/null +++ b/selenium/che-selenium-test/src/test/resources/projects/plugins/JavaTestRunnerPlugin/junit4-tests-with-separeted-suites/src/main/java/org/eclipse/che/example/Hello.java @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2012-2017 Red Hat, Inc. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Red Hat, Inc. - initial API and implementation + */ +package org.eclipse.che.example; + +public class Hello { + + + public boolean returnTrue() { + return true; + } + + public String returnHello () { + String message = "Hello IDE"; + return message; + } + +} diff --git a/selenium/che-selenium-test/src/test/resources/projects/plugins/JavaTestRunnerPlugin/junit4-tests-with-separeted-suites/src/main/java/org/eclipse/che/example/HelloWorld.java b/selenium/che-selenium-test/src/test/resources/projects/plugins/JavaTestRunnerPlugin/junit4-tests-with-separeted-suites/src/main/java/org/eclipse/che/example/HelloWorld.java new file mode 100644 index 00000000000..5ca80679518 --- /dev/null +++ b/selenium/che-selenium-test/src/test/resources/projects/plugins/JavaTestRunnerPlugin/junit4-tests-with-separeted-suites/src/main/java/org/eclipse/che/example/HelloWorld.java @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2012-2017 Red Hat, Inc. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Red Hat, Inc. - initial API and implementation + */ +package org.eclipse.che.example; +public class HelloWorld { + + public static void main(String[] argvs) { + String a = "Che"; + System.out.println("Hello World " + a + "!"); + } + + public boolean returnTrue() { + return true; + } +} diff --git a/selenium/che-selenium-test/src/test/resources/projects/plugins/JavaTestRunnerPlugin/junit4-tests-with-separeted-suites/src/test/java/org/eclipse/che/suite/Junit4TestSuite.java b/selenium/che-selenium-test/src/test/resources/projects/plugins/JavaTestRunnerPlugin/junit4-tests-with-separeted-suites/src/test/java/org/eclipse/che/suite/Junit4TestSuite.java new file mode 100644 index 00000000000..08af2bc5f89 --- /dev/null +++ b/selenium/che-selenium-test/src/test/resources/projects/plugins/JavaTestRunnerPlugin/junit4-tests-with-separeted-suites/src/test/java/org/eclipse/che/suite/Junit4TestSuite.java @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2012-2017 Red Hat, Inc. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Red Hat, Inc. - initial API and implementation + */ +package org.eclipse.che.suite; + +import org.eclipse.che.tests.AppAnotherTest; +import org.junit.runner.RunWith; +import org.junit.runners.Suite; +/** + * JUnit 4x Test Suite + */ +@RunWith(Suite.class) +@Suite.SuiteClasses({AppAnotherTest.class, + AppAnotherTest.class}) +public class Junit4TestSuite { +} diff --git a/selenium/che-selenium-test/src/test/resources/projects/plugins/JavaTestRunnerPlugin/junit4-tests-with-separeted-suites/src/test/java/org/eclipse/che/tests/AppAnotherTest.java b/selenium/che-selenium-test/src/test/resources/projects/plugins/JavaTestRunnerPlugin/junit4-tests-with-separeted-suites/src/test/java/org/eclipse/che/tests/AppAnotherTest.java new file mode 100644 index 00000000000..19bc0480a35 --- /dev/null +++ b/selenium/che-selenium-test/src/test/resources/projects/plugins/JavaTestRunnerPlugin/junit4-tests-with-separeted-suites/src/test/java/org/eclipse/che/tests/AppAnotherTest.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2012-2017 Red Hat, Inc. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Red Hat, Inc. - initial API and implementation + */ +package org.eclipse.che.tests; + +import org.eclipse.che.example.Hello; +import org.junit.Test; +import static org.junit.Assert.assertTrue; + +/** + * Unit test for simple App. + */ +public class AppAnotherTest { + + @Test + public void shouldSuccessOfAppAnother() { + assertTrue(new Hello().returnHello().startsWith("Hello")); + } + + @Test + public void shouldFailOfAppAnother() { + assertTrue(new Hello().returnHello().endsWith("Hello")); + } + + +} diff --git a/selenium/che-selenium-test/src/test/resources/projects/plugins/JavaTestRunnerPlugin/junit4-tests-with-separeted-suites/src/test/java/org/eclipse/che/tests/AppOneTest.java b/selenium/che-selenium-test/src/test/resources/projects/plugins/JavaTestRunnerPlugin/junit4-tests-with-separeted-suites/src/test/java/org/eclipse/che/tests/AppOneTest.java new file mode 100644 index 00000000000..90ca4078848 --- /dev/null +++ b/selenium/che-selenium-test/src/test/resources/projects/plugins/JavaTestRunnerPlugin/junit4-tests-with-separeted-suites/src/test/java/org/eclipse/che/tests/AppOneTest.java @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2012-2017 Red Hat, Inc. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Red Hat, Inc. - initial API and implementation + */ +package org.eclipse.che.tests; + +import org.eclipse.che.example.HelloWorld; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +/** + * Unit test for simple App. + */ +public class AppOneTest { + + @Test + public void shouldSuccessOfAppOne() { + assertTrue(new HelloWorld().returnTrue()); + } + + @Test + public void shouldFailOfAppOne() { + assertFalse(new HelloWorld().returnTrue()); + } + + @Test + @Ignore + public void shouldBeIgnoredOfAppOne(){ Assert.fail();} +} From d3c23df1849a2d1bdb396c70f16b0a7bd18a44f0 Mon Sep 17 00:00:00 2001 From: Maxim Musienko Date: Fri, 22 Sep 2017 15:14:01 +0300 Subject: [PATCH 4/9] remove unnecessary fields and methods, fix syntax errors --- .../che/selenium/pageobject/CodenvyEditor.java | 16 ---------------- .../che/selenium/pageobject/Consoles.java | 9 ++++----- .../plugins/JavaTestRunnerPluginConsole.java | 3 +-- ...PluginJuinit4CheckRunSuitesAndScopesTest.java | 2 +- .../src/test/resources/suites/CheSuite.xml | 1 + 5 files changed, 7 insertions(+), 24 deletions(-) diff --git a/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/pageobject/CodenvyEditor.java b/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/pageobject/CodenvyEditor.java index a7714252107..2fb59c38c27 100644 --- a/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/pageobject/CodenvyEditor.java +++ b/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/pageobject/CodenvyEditor.java @@ -38,7 +38,6 @@ import java.util.stream.Collectors; import org.eclipse.che.selenium.core.SeleniumWebDriver; import org.eclipse.che.selenium.core.action.ActionsFactory; -import org.eclipse.che.selenium.core.constant.TestMenuCommandsConstants; import org.eclipse.che.selenium.core.utils.WaitUtils; import org.openqa.selenium.By; import org.openqa.selenium.Keys; @@ -61,8 +60,6 @@ public class CodenvyEditor { public static final String CLOSE_ALL_TABS = "gwt-debug-contextMenu/closeAllEditors"; - @Inject private Menu menu; - public static final class EditorContextMenu { public static final String REFACTORING = "contextMenu/Refactoring"; public static final String REFACTORING_MOVE = "contextMenu/Refactoring/Move"; @@ -514,19 +511,6 @@ public void setCursorToDefinedLineAndChar(int positionLine, int positionChar) { waitSpecifiedValueForLineAndChar(positionLine, positionChar); } - public void setCursorToDefinedLineAndCharByMenu() { - menu.runCommand( - TestMenuCommandsConstants.Run.RUN_MENU, TestMenuCommandsConstants.Run.DEBUG_CONFIGURATION); - } - - /** - * set cursor in specified position - * - * @param positionLine is the specified number line - * @param positionChar is the specified number char - */ - public void setCursorToDefinedLineAndCharByMenu(int positionLine, int positionChar) {} - /** launch code assistant with ctrl+space keys and wait container is open */ public void launchAutocompleteAndWaitContainer() { loader.waitOnClosed(); diff --git a/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/pageobject/Consoles.java b/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/pageobject/Consoles.java index 5f36b6e344f..052ce32a88f 100644 --- a/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/pageobject/Consoles.java +++ b/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/pageobject/Consoles.java @@ -75,7 +75,7 @@ public Consoles(SeleniumWebDriver seleniumWebDriver, Loader loader) { } @FindBy(css = CONSOLE_PANEL_DRUGGER_CSS) - WebElement consolesPanelDrugger; + WebElement consolesPanelDrag; @FindBy(id = PROCESSES_TAB) WebElement processesTab; @@ -310,9 +310,8 @@ public void clickOnMaximizePanelIcon() { * * @param xoffset offset in pixels for shifting */ - public void drugConsolesInDefinePosition(int xoffset) { - WebElement drugger = - redrawDriverWait.until(ExpectedConditions.visibilityOf(consolesPanelDrugger)); - new Actions(seleniumWebDriver).dragAndDropBy(drugger, xoffset, xoffset).perform(); + public void dragConsolesInDefinePosition(int xoffset) { + WebElement drag = redrawDriverWait.until(ExpectedConditions.visibilityOf(consolesPanelDrag)); + new Actions(seleniumWebDriver).dragAndDropBy(drag, xoffset, xoffset).perform(); } } diff --git a/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/pageobject/plugins/JavaTestRunnerPluginConsole.java b/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/pageobject/plugins/JavaTestRunnerPluginConsole.java index 0b72b149fa9..64da7c0f6f2 100644 --- a/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/pageobject/plugins/JavaTestRunnerPluginConsole.java +++ b/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/pageobject/plugins/JavaTestRunnerPluginConsole.java @@ -43,7 +43,6 @@ public class JavaTestRunnerPluginConsole extends Consoles { "//div[contains(@id,'gwt-uid')]//div[@style='color: red;']"; private static final String METHODS_MARKED_AS_IGNORED = "//div[contains(@id,'gwt-uid')]//div[@style='text-decoration: line-through; color: yellow;']"; - private static final String TEST_RESULT_TREE_ITEM = "gwt-debug-test-tree-navigation-panel"; private static final String TEST_RESULT_NAVIGATION_TREE = "gwt-debug-test-tree-navigation-panel"; @@ -188,7 +187,7 @@ private List getAllMetodsWithDefinedStatus(List definedMetho } /** - * get taxt from the test result tree. Mote! This method represent only text from test result tree + * get text from the test result tree. Mote! This method represent only text from test result tree * without styles and formatting * * @return text representation of results of the test result tree widget diff --git a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/testrunner/JavaTestPluginJuinit4CheckRunSuitesAndScopesTest.java b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/testrunner/JavaTestPluginJuinit4CheckRunSuitesAndScopesTest.java index 04580a41b5d..5b0d3bb1249 100644 --- a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/testrunner/JavaTestPluginJuinit4CheckRunSuitesAndScopesTest.java +++ b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/testrunner/JavaTestPluginJuinit4CheckRunSuitesAndScopesTest.java @@ -74,7 +74,7 @@ public void prepareTestProject() throws Exception { projectExplorer.waitItem(JUNIT4_PROJECT); runCompileCommandByPallete(compileCommand); notifications.waitProgressPopupPanelClose(); - consoles.drugConsolesInDefinePosition(-100); + consoles.dragConsolesInDefinePosition(-100); } @Test diff --git a/selenium/che-selenium-test/src/test/resources/suites/CheSuite.xml b/selenium/che-selenium-test/src/test/resources/suites/CheSuite.xml index 531447df1fb..579c4910c17 100644 --- a/selenium/che-selenium-test/src/test/resources/suites/CheSuite.xml +++ b/selenium/che-selenium-test/src/test/resources/suites/CheSuite.xml @@ -546,6 +546,7 @@ + From acb14d03b4d7ef6d79788df1ff9df6feb25a4bea Mon Sep 17 00:00:00 2001 From: Maxim Musienko Date: Mon, 25 Sep 2017 17:31:29 +0300 Subject: [PATCH 5/9] use static import in the all places --- .../testrunner/JavaTestPluginJunit4Test.java | 49 ++++++++++--------- .../testrunner/JavaTestPluginTestNgTest.java | 33 +++++++------ 2 files changed, 42 insertions(+), 40 deletions(-) diff --git a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/testrunner/JavaTestPluginJunit4Test.java b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/testrunner/JavaTestPluginJunit4Test.java index 240558d7087..202e0e70abd 100644 --- a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/testrunner/JavaTestPluginJunit4Test.java +++ b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/testrunner/JavaTestPluginJunit4Test.java @@ -10,16 +10,8 @@ */ package org.eclipse.che.selenium.testrunner; -import static org.eclipse.che.selenium.core.constant.TestMenuCommandsConstants.Run.RUN_MENU; -import static org.eclipse.che.selenium.core.constant.TestMenuCommandsConstants.Run.TEST; -import static org.eclipse.che.selenium.core.constant.TestMenuCommandsConstants.TEST_DROP_DAWN_ITEM; -import static org.eclipse.che.selenium.pageobject.plugins.JavaTestRunnerPluginConsole.JunitMethodsState.FAILED; -import static org.eclipse.che.selenium.pageobject.plugins.JavaTestRunnerPluginConsole.JunitMethodsState.IGNORED; -import static org.eclipse.che.selenium.pageobject.plugins.JavaTestRunnerPluginConsole.JunitMethodsState.PASSED; -import static org.testng.Assert.assertTrue; - import com.google.inject.Inject; -import java.nio.file.Paths; + import org.eclipse.che.api.workspace.server.DtoConverter; import org.eclipse.che.selenium.core.client.TestCommandServiceClient; import org.eclipse.che.selenium.core.client.TestProjectServiceClient; @@ -35,10 +27,19 @@ import org.eclipse.che.selenium.pageobject.ProjectExplorer; import org.eclipse.che.selenium.pageobject.intelligent.CommandsPalette; import org.eclipse.che.selenium.pageobject.plugins.JavaTestRunnerPluginConsole; -import org.testng.Assert; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +import java.nio.file.Paths; + +import static org.eclipse.che.selenium.core.constant.TestMenuCommandsConstants.Run.RUN_MENU; +import static org.eclipse.che.selenium.core.constant.TestMenuCommandsConstants.Run.TEST; +import static org.eclipse.che.selenium.core.constant.TestMenuCommandsConstants.TEST_DROP_DAWN_ITEM; +import static org.eclipse.che.selenium.pageobject.plugins.JavaTestRunnerPluginConsole.JunitMethodsState.FAILED; +import static org.eclipse.che.selenium.pageobject.plugins.JavaTestRunnerPluginConsole.JunitMethodsState.IGNORED; +import static org.eclipse.che.selenium.pageobject.plugins.JavaTestRunnerPluginConsole.JunitMethodsState.PASSED; +import static org.testng.Assert.assertTrue; + /** @author Dmytro Nochevnov */ public class JavaTestPluginJunit4Test { @@ -52,18 +53,18 @@ public class JavaTestPluginJunit4Test { public static final String APP_TEST_ONE_FAIL_OUTPUT_TEMPLATE = "java.lang.AssertionError\n" - + " at org.junit.Assert.fail(Assert.java:86)\n" - + " at org.junit.Assert.assertTrue(Assert.java:41)\n" - + " at org.junit.Assert.assertFalse(Assert.java:64)\n" - + " at org.junit.Assert.assertFalse(Assert.java:74)\n" + + " at org.junit. fail( java:86)\n" + + " at org.junit. assertTrue( java:41)\n" + + " at org.junit. assertFalse( java:64)\n" + + " at org.junit. assertFalse( java:74)\n" + " at org.eclipse.che.examples.AppOneTest.shouldFailOfAppOne(AppOneTest.java:33)"; public static final String APP_TEST_ANOTHER_FAIL_OUTPUT_TEMPLATE = "java.lang.AssertionError\n" - + " at org.junit.Assert.fail(Assert.java:86)\n" - + " at org.junit.Assert.assertTrue(Assert.java:41)\n" - + " at org.junit.Assert.assertFalse(Assert.java:64)\n" - + " at org.junit.Assert.assertFalse(Assert.java:74)\n" + + " at org.junit. fail( java:86)\n" + + " at org.junit. assertTrue( java:41)\n" + + " at org.junit. assertFalse( java:64)\n" + + " at org.junit. assertFalse( java:74)\n" + " at org.eclipse.che.examples.AppAnotherTest.shouldFailOfAppAnother(AppAnotherTest.java:34)"; @Inject private JavaTestRunnerPluginConsole pluginConsole; @@ -123,9 +124,9 @@ public void shouldExecuteJUnit4TestClassWithDifferentStatuses() throws Interrupt pluginConsole.waitMethodMarkedAsPassed("shouldSuccessOfAppOne"); pluginConsole.waitMethodMarkedAsFailed("shouldFailOfAppOne"); pluginConsole.waitMethodMarkedAsIgnored("shouldBeIgnoredOfAppOne"); - Assert.assertTrue(pluginConsole.getAllNamesOfMethodsMarkedDefinedStatus(PASSED).size() == 1); - Assert.assertTrue(pluginConsole.getAllNamesOfMethodsMarkedDefinedStatus(FAILED).size() == 1); - Assert.assertTrue(pluginConsole.getAllNamesOfMethodsMarkedDefinedStatus(IGNORED).size() == 1); + assertTrue(pluginConsole.getAllNamesOfMethodsMarkedDefinedStatus(PASSED).size() == 1); + assertTrue(pluginConsole.getAllNamesOfMethodsMarkedDefinedStatus(FAILED).size() == 1); + assertTrue(pluginConsole.getAllNamesOfMethodsMarkedDefinedStatus(IGNORED).size() == 1); String testErrorMessage = pluginConsole.getTestErrorMessage(); assertTrue( testErrorMessage.startsWith(APP_TEST_ONE_FAIL_OUTPUT_TEMPLATE), @@ -147,14 +148,14 @@ public void shouldExecuteJUnit4MethodWithDifferentStatuses() throws InterruptedE // then pluginConsole.waitFqnOfTesClassInResultTree("org.eclipse.che.examples.AppAnotherTest"); pluginConsole.waitMethodMarkedAsPassed("shouldSuccessOfAppAnother"); - Assert.assertTrue(pluginConsole.getAllNamesOfMethodsMarkedDefinedStatus(PASSED).size() == 1); + assertTrue(pluginConsole.getAllNamesOfMethodsMarkedDefinedStatus(PASSED).size() == 1); // then editor.setCursorToDefinedLineAndChar(32, 5); menu.runCommand(RUN_MENU, TEST, TEST_DROP_DAWN_ITEM); notifications.waitExpectedMessageOnProgressPanelAndClosed("Test runner executed successfully."); pluginConsole.waitMethodMarkedAsFailed("shouldFailOfAppAnother"); - Assert.assertTrue(pluginConsole.getAllNamesOfMethodsMarkedDefinedStatus(FAILED).size() == 1); + assertTrue(pluginConsole.getAllNamesOfMethodsMarkedDefinedStatus(FAILED).size() == 1); String testErrorMessage = pluginConsole.getTestErrorMessage(); assertTrue( testErrorMessage.startsWith(APP_TEST_ANOTHER_FAIL_OUTPUT_TEMPLATE), @@ -164,6 +165,6 @@ public void shouldExecuteJUnit4MethodWithDifferentStatuses() throws InterruptedE menu.runCommand(RUN_MENU, TEST, TEST_DROP_DAWN_ITEM); notifications.waitExpectedMessageOnProgressPanelAndClosed("Test runner executed successfully."); pluginConsole.waitMethodMarkedAsIgnored("shouldBeIgnoredOfAppAnother"); - Assert.assertTrue(pluginConsole.getAllNamesOfMethodsMarkedDefinedStatus(IGNORED).size() == 1); + assertTrue(pluginConsole.getAllNamesOfMethodsMarkedDefinedStatus(IGNORED).size() == 1); } } diff --git a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/testrunner/JavaTestPluginTestNgTest.java b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/testrunner/JavaTestPluginTestNgTest.java index 974241d7473..6da4da36af5 100644 --- a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/testrunner/JavaTestPluginTestNgTest.java +++ b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/testrunner/JavaTestPluginTestNgTest.java @@ -10,16 +10,8 @@ */ package org.eclipse.che.selenium.testrunner; -import static org.eclipse.che.selenium.core.constant.TestMenuCommandsConstants.Run.RUN_MENU; -import static org.eclipse.che.selenium.core.constant.TestMenuCommandsConstants.Run.TEST; -import static org.eclipse.che.selenium.core.constant.TestMenuCommandsConstants.TEST_NG_TEST_DROP_DAWN_ITEM; -import static org.eclipse.che.selenium.pageobject.plugins.JavaTestRunnerPluginConsole.JunitMethodsState.FAILED; -import static org.eclipse.che.selenium.pageobject.plugins.JavaTestRunnerPluginConsole.JunitMethodsState.PASSED; -import static org.testng.Assert.assertTrue; - import com.google.inject.Inject; -import java.net.URL; -import java.nio.file.Paths; + import org.eclipse.che.api.workspace.server.DtoConverter; import org.eclipse.che.selenium.core.client.TestCommandServiceClient; import org.eclipse.che.selenium.core.client.TestProjectServiceClient; @@ -38,10 +30,19 @@ import org.eclipse.che.selenium.pageobject.ProjectExplorer; import org.eclipse.che.selenium.pageobject.intelligent.CommandsPalette; import org.eclipse.che.selenium.pageobject.plugins.JavaTestRunnerPluginConsole; -import org.testng.Assert; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +import java.net.URL; +import java.nio.file.Paths; + +import static org.eclipse.che.selenium.core.constant.TestMenuCommandsConstants.Run.RUN_MENU; +import static org.eclipse.che.selenium.core.constant.TestMenuCommandsConstants.Run.TEST; +import static org.eclipse.che.selenium.core.constant.TestMenuCommandsConstants.TEST_NG_TEST_DROP_DAWN_ITEM; +import static org.eclipse.che.selenium.pageobject.plugins.JavaTestRunnerPluginConsole.JunitMethodsState.FAILED; +import static org.eclipse.che.selenium.pageobject.plugins.JavaTestRunnerPluginConsole.JunitMethodsState.PASSED; +import static org.testng.Assert.assertTrue; + /** @author Dmytro Nochevnov */ public class JavaTestPluginTestNgTest { @@ -122,8 +123,8 @@ public void shouldExecuteTestClassSuccessfully() throws InterruptedException { notifications.waitExpectedMessageOnProgressPanelAndClosed("Test runner executed successfully."); pluginConsole.waitMethodMarkedAsPassed("shouldSuccessOfAppOne"); pluginConsole.waitMethodMarkedAsFailed("shouldFailOfAppOne"); - Assert.assertTrue(pluginConsole.getAllNamesOfMethodsMarkedDefinedStatus(PASSED).size() == 1); - Assert.assertTrue(pluginConsole.getAllNamesOfMethodsMarkedDefinedStatus(FAILED).size() == 1); + assertTrue(pluginConsole.getAllNamesOfMethodsMarkedDefinedStatus(PASSED).size() == 1); + assertTrue(pluginConsole.getAllNamesOfMethodsMarkedDefinedStatus(FAILED).size() == 1); String testErrorMessage = pluginConsole.getTestErrorMessage(); assertTrue( testErrorMessage.startsWith(APP_TEST_ONE_FAIL_OUTPUT_TEMPLATE), @@ -141,11 +142,11 @@ public void shouldExecuteTestMethodsSuccessfully() throws InterruptedException { menu.runCommand(RUN_MENU, TEST, TEST_NG_TEST_DROP_DAWN_ITEM); notifications.waitExpectedMessageOnProgressPanelAndClosed("Test runner executed successfully."); pluginConsole.waitMethodMarkedAsPassed("shouldSuccessOfAppAnother"); - Assert.assertTrue(pluginConsole.getAllNamesOfMethodsMarkedDefinedStatus(PASSED).size() == 1); + assertTrue(pluginConsole.getAllNamesOfMethodsMarkedDefinedStatus(PASSED).size() == 1); editor.setCursorToDefinedLineAndChar(30, 17); menu.runCommand(RUN_MENU, TEST, TEST_NG_TEST_DROP_DAWN_ITEM); pluginConsole.waitMethodMarkedAsFailed("shouldFailOfAppAnother"); - Assert.assertTrue(pluginConsole.getAllNamesOfMethodsMarkedDefinedStatus(FAILED).size() == 1); + assertTrue(pluginConsole.getAllNamesOfMethodsMarkedDefinedStatus(FAILED).size() == 1); String testErrorMessage = pluginConsole.getTestErrorMessage(); assertTrue( testErrorMessage.startsWith(APP_TEST_ANOTHER_FAIL_OUTPUT_TEMPLATE), @@ -165,11 +166,11 @@ public void shouldExecuteAlltets() throws InterruptedException { menu.runCommand(RUN_MENU, TEST, TEST_NG_TEST_DROP_DAWN_ITEM); notifications.waitExpectedMessageOnProgressPanelAndClosed("Test runner executed successfully."); pluginConsole.waitMethodMarkedAsPassed("shouldSuccessOfAppAnother"); - Assert.assertTrue(pluginConsole.getAllNamesOfMethodsMarkedDefinedStatus(PASSED).size() == 1); + assertTrue(pluginConsole.getAllNamesOfMethodsMarkedDefinedStatus(PASSED).size() == 1); editor.setCursorToDefinedLineAndChar(30, 17); menu.runCommand(RUN_MENU, TEST, TEST_NG_TEST_DROP_DAWN_ITEM); pluginConsole.waitMethodMarkedAsFailed("shouldFailOfAppAnother"); - Assert.assertTrue(pluginConsole.getAllNamesOfMethodsMarkedDefinedStatus(FAILED).size() == 1); + assertTrue(pluginConsole.getAllNamesOfMethodsMarkedDefinedStatus(FAILED).size() == 1); String testErrorMessage = pluginConsole.getTestErrorMessage(); assertTrue( testErrorMessage.startsWith(APP_TEST_ANOTHER_FAIL_OUTPUT_TEMPLATE), From 27e9b0d65dc57fc75314d75645abb2f5179d319f Mon Sep 17 00:00:00 2001 From: Maxim Musienko Date: Mon, 25 Sep 2017 17:55:12 +0300 Subject: [PATCH 6/9] apply formatting --- .../testrunner/JavaTestPluginJunit4Test.java | 20 +++++++++---------- .../testrunner/JavaTestPluginTestNgTest.java | 20 +++++++++---------- 2 files changed, 18 insertions(+), 22 deletions(-) diff --git a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/testrunner/JavaTestPluginJunit4Test.java b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/testrunner/JavaTestPluginJunit4Test.java index 202e0e70abd..19681e2a156 100644 --- a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/testrunner/JavaTestPluginJunit4Test.java +++ b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/testrunner/JavaTestPluginJunit4Test.java @@ -10,8 +10,16 @@ */ package org.eclipse.che.selenium.testrunner; -import com.google.inject.Inject; +import static org.eclipse.che.selenium.core.constant.TestMenuCommandsConstants.Run.RUN_MENU; +import static org.eclipse.che.selenium.core.constant.TestMenuCommandsConstants.Run.TEST; +import static org.eclipse.che.selenium.core.constant.TestMenuCommandsConstants.TEST_DROP_DAWN_ITEM; +import static org.eclipse.che.selenium.pageobject.plugins.JavaTestRunnerPluginConsole.JunitMethodsState.FAILED; +import static org.eclipse.che.selenium.pageobject.plugins.JavaTestRunnerPluginConsole.JunitMethodsState.IGNORED; +import static org.eclipse.che.selenium.pageobject.plugins.JavaTestRunnerPluginConsole.JunitMethodsState.PASSED; +import static org.testng.Assert.assertTrue; +import com.google.inject.Inject; +import java.nio.file.Paths; import org.eclipse.che.api.workspace.server.DtoConverter; import org.eclipse.che.selenium.core.client.TestCommandServiceClient; import org.eclipse.che.selenium.core.client.TestProjectServiceClient; @@ -30,16 +38,6 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import java.nio.file.Paths; - -import static org.eclipse.che.selenium.core.constant.TestMenuCommandsConstants.Run.RUN_MENU; -import static org.eclipse.che.selenium.core.constant.TestMenuCommandsConstants.Run.TEST; -import static org.eclipse.che.selenium.core.constant.TestMenuCommandsConstants.TEST_DROP_DAWN_ITEM; -import static org.eclipse.che.selenium.pageobject.plugins.JavaTestRunnerPluginConsole.JunitMethodsState.FAILED; -import static org.eclipse.che.selenium.pageobject.plugins.JavaTestRunnerPluginConsole.JunitMethodsState.IGNORED; -import static org.eclipse.che.selenium.pageobject.plugins.JavaTestRunnerPluginConsole.JunitMethodsState.PASSED; -import static org.testng.Assert.assertTrue; - /** @author Dmytro Nochevnov */ public class JavaTestPluginJunit4Test { diff --git a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/testrunner/JavaTestPluginTestNgTest.java b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/testrunner/JavaTestPluginTestNgTest.java index 6da4da36af5..7f610fcbbf6 100644 --- a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/testrunner/JavaTestPluginTestNgTest.java +++ b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/testrunner/JavaTestPluginTestNgTest.java @@ -10,8 +10,16 @@ */ package org.eclipse.che.selenium.testrunner; -import com.google.inject.Inject; +import static org.eclipse.che.selenium.core.constant.TestMenuCommandsConstants.Run.RUN_MENU; +import static org.eclipse.che.selenium.core.constant.TestMenuCommandsConstants.Run.TEST; +import static org.eclipse.che.selenium.core.constant.TestMenuCommandsConstants.TEST_NG_TEST_DROP_DAWN_ITEM; +import static org.eclipse.che.selenium.pageobject.plugins.JavaTestRunnerPluginConsole.JunitMethodsState.FAILED; +import static org.eclipse.che.selenium.pageobject.plugins.JavaTestRunnerPluginConsole.JunitMethodsState.PASSED; +import static org.testng.Assert.assertTrue; +import com.google.inject.Inject; +import java.net.URL; +import java.nio.file.Paths; import org.eclipse.che.api.workspace.server.DtoConverter; import org.eclipse.che.selenium.core.client.TestCommandServiceClient; import org.eclipse.che.selenium.core.client.TestProjectServiceClient; @@ -33,16 +41,6 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import java.net.URL; -import java.nio.file.Paths; - -import static org.eclipse.che.selenium.core.constant.TestMenuCommandsConstants.Run.RUN_MENU; -import static org.eclipse.che.selenium.core.constant.TestMenuCommandsConstants.Run.TEST; -import static org.eclipse.che.selenium.core.constant.TestMenuCommandsConstants.TEST_NG_TEST_DROP_DAWN_ITEM; -import static org.eclipse.che.selenium.pageobject.plugins.JavaTestRunnerPluginConsole.JunitMethodsState.FAILED; -import static org.eclipse.che.selenium.pageobject.plugins.JavaTestRunnerPluginConsole.JunitMethodsState.PASSED; -import static org.testng.Assert.assertTrue; - /** @author Dmytro Nochevnov */ public class JavaTestPluginTestNgTest { From 775e9a265ff21a09a24f832c28fee40e434ac8f0 Mon Sep 17 00:00:00 2001 From: Maxim Musienko Date: Tue, 26 Sep 2017 10:18:03 +0300 Subject: [PATCH 7/9] fix typo, remove unnecessary methods --- .../org/eclipse/che/selenium/pageobject/Consoles.java | 10 +++------- ...vaTestPluginJunit4CheckRunSuitesAndScopesTest.java} | 6 ++++-- .../src/test/resources/suites/CheSuite.xml | 2 +- 3 files changed, 8 insertions(+), 10 deletions(-) rename selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/testrunner/{JavaTestPluginJuinit4CheckRunSuitesAndScopesTest.java => JavaTestPluginJunit4CheckRunSuitesAndScopesTest.java} (96%) diff --git a/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/pageobject/Consoles.java b/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/pageobject/Consoles.java index 052ce32a88f..1f47acde84c 100644 --- a/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/pageobject/Consoles.java +++ b/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/pageobject/Consoles.java @@ -305,13 +305,9 @@ public void clickOnMaximizePanelIcon() { redrawDriverWait.until(elementToBeClickable(By.xpath(MAXIMIZE_PANEL_ICON))).click(); } - /** - * * apply drug and drop feature for consoles feature, shift the work bench panel up or down - * - * @param xoffset offset in pixels for shifting - */ - public void dragConsolesInDefinePosition(int xoffset) { + + public void dragConsolesInDefinePosition(int verticalShiftInPixels) { WebElement drag = redrawDriverWait.until(ExpectedConditions.visibilityOf(consolesPanelDrag)); - new Actions(seleniumWebDriver).dragAndDropBy(drag, xoffset, xoffset).perform(); + new Actions(seleniumWebDriver).dragAndDropBy(drag, verticalShiftInPixels, verticalShiftInPixels).perform(); } } diff --git a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/testrunner/JavaTestPluginJuinit4CheckRunSuitesAndScopesTest.java b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/testrunner/JavaTestPluginJunit4CheckRunSuitesAndScopesTest.java similarity index 96% rename from selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/testrunner/JavaTestPluginJuinit4CheckRunSuitesAndScopesTest.java rename to selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/testrunner/JavaTestPluginJunit4CheckRunSuitesAndScopesTest.java index 5b0d3bb1249..0e9be6ca88b 100644 --- a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/testrunner/JavaTestPluginJuinit4CheckRunSuitesAndScopesTest.java +++ b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/testrunner/JavaTestPluginJunit4CheckRunSuitesAndScopesTest.java @@ -34,7 +34,7 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -public class JavaTestPluginJuinit4CheckRunSuitesAndScopesTest { +public class JavaTestPluginJunit4CheckRunSuitesAndScopesTest { private static final String JUNIT4_PROJECT = "junit4-tests-with-separeted-suites"; private static final String PATH_TO_JUNIT4_TEST_CLASSES = @@ -42,6 +42,8 @@ public class JavaTestPluginJuinit4CheckRunSuitesAndScopesTest { private static final String PATH_TO_JUNIT4_TEST_SUITE = JUNIT4_PROJECT + "/src/tests/java/org/examples/suite/Junit4TestSuite.java"; + private static final int VALUE_OF_SHIFTING_CONSOLES_ALONG_X_AXIS = -100; + @Inject private JavaTestRunnerPluginConsole pluginConsole; @Inject private ProjectExplorer projectExplorer; @Inject private Loader loader; @@ -74,7 +76,7 @@ public void prepareTestProject() throws Exception { projectExplorer.waitItem(JUNIT4_PROJECT); runCompileCommandByPallete(compileCommand); notifications.waitProgressPopupPanelClose(); - consoles.dragConsolesInDefinePosition(-100); + consoles.dragConsolesInDefinePosition(VALUE_OF_SHIFTING_CONSOLES_ALONG_X_AXIS); } @Test diff --git a/selenium/che-selenium-test/src/test/resources/suites/CheSuite.xml b/selenium/che-selenium-test/src/test/resources/suites/CheSuite.xml index 579c4910c17..1d489876ee7 100644 --- a/selenium/che-selenium-test/src/test/resources/suites/CheSuite.xml +++ b/selenium/che-selenium-test/src/test/resources/suites/CheSuite.xml @@ -546,7 +546,7 @@ - + From 439001d458799aa346fd5ba56f88c6515f235b3d Mon Sep 17 00:00:00 2001 From: Maxim Musienko Date: Tue, 26 Sep 2017 13:10:17 +0300 Subject: [PATCH 8/9] fix typo, java docks, remove unused fields --- .../che/selenium/pageobject/Consoles.java | 5 +++-- ...luginJunit4CheckRunSuitesAndScopesTest.java | 2 -- .../testrunner/JavaTestPluginJunit4Test.java | 18 ++++++++---------- .../testrunner/JavaTestPluginTestNgTest.java | 4 ---- 4 files changed, 11 insertions(+), 18 deletions(-) diff --git a/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/pageobject/Consoles.java b/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/pageobject/Consoles.java index 1f47acde84c..3219973aca1 100644 --- a/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/pageobject/Consoles.java +++ b/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/pageobject/Consoles.java @@ -305,9 +305,10 @@ public void clickOnMaximizePanelIcon() { redrawDriverWait.until(elementToBeClickable(By.xpath(MAXIMIZE_PANEL_ICON))).click(); } - public void dragConsolesInDefinePosition(int verticalShiftInPixels) { WebElement drag = redrawDriverWait.until(ExpectedConditions.visibilityOf(consolesPanelDrag)); - new Actions(seleniumWebDriver).dragAndDropBy(drag, verticalShiftInPixels, verticalShiftInPixels).perform(); + new Actions(seleniumWebDriver) + .dragAndDropBy(drag, verticalShiftInPixels, verticalShiftInPixels) + .perform(); } } diff --git a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/testrunner/JavaTestPluginJunit4CheckRunSuitesAndScopesTest.java b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/testrunner/JavaTestPluginJunit4CheckRunSuitesAndScopesTest.java index 0e9be6ca88b..a4a03752963 100644 --- a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/testrunner/JavaTestPluginJunit4CheckRunSuitesAndScopesTest.java +++ b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/testrunner/JavaTestPluginJunit4CheckRunSuitesAndScopesTest.java @@ -39,8 +39,6 @@ public class JavaTestPluginJunit4CheckRunSuitesAndScopesTest { private static final String PATH_TO_JUNIT4_TEST_CLASSES = JUNIT4_PROJECT + "/src/test/java/org/eclipse/che/tests/AppOneTest.java"; - private static final String PATH_TO_JUNIT4_TEST_SUITE = - JUNIT4_PROJECT + "/src/tests/java/org/examples/suite/Junit4TestSuite.java"; private static final int VALUE_OF_SHIFTING_CONSOLES_ALONG_X_AXIS = -100; diff --git a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/testrunner/JavaTestPluginJunit4Test.java b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/testrunner/JavaTestPluginJunit4Test.java index 19681e2a156..b119d584e82 100644 --- a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/testrunner/JavaTestPluginJunit4Test.java +++ b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/testrunner/JavaTestPluginJunit4Test.java @@ -46,23 +46,21 @@ public class JavaTestPluginJunit4Test { JUNIT4_PROJECT + "/src/test/java/org/eclipse/che/examples/AppOneTest.java"; private static final String PATH_TO_JUNIT4_ANOTHER_TEST = JUNIT4_PROJECT + "/src/test/java/org/eclipse/che/examples/AppAnotherTest.java"; - private static final String PATH_TO_JUNIT4_TEST_SUITE = - JUNIT4_PROJECT + "/src/test/java/org/eclipse/che/examples/Junit4TestSuite.java"; public static final String APP_TEST_ONE_FAIL_OUTPUT_TEMPLATE = "java.lang.AssertionError\n" - + " at org.junit. fail( java:86)\n" - + " at org.junit. assertTrue( java:41)\n" - + " at org.junit. assertFalse( java:64)\n" - + " at org.junit. assertFalse( java:74)\n" + + " at org.junit.Assert.fail(Assert.java:86)\n" + + " at org.junit.Assert.assertTrue(Assert.java:41)\n" + + " at org.junit.Assert.assertFalse(Assert.java:64)\n" + + " at org.junit.Assert.assertFalse(Assert.java:74)\n" + " at org.eclipse.che.examples.AppOneTest.shouldFailOfAppOne(AppOneTest.java:33)"; public static final String APP_TEST_ANOTHER_FAIL_OUTPUT_TEMPLATE = "java.lang.AssertionError\n" - + " at org.junit. fail( java:86)\n" - + " at org.junit. assertTrue( java:41)\n" - + " at org.junit. assertFalse( java:64)\n" - + " at org.junit. assertFalse( java:74)\n" + + " at org.junit.Assert.fail(Assert.java:86)\n" + + " at org.junit.Assert.assertTrue(Assert.java:41)\n" + + " at org.junit.Assert.assertFalse(Assert.java:64)\n" + + " at org.junit.Assert.assertFalse(Assert.java:74)\n" + " at org.eclipse.che.examples.AppAnotherTest.shouldFailOfAppAnother(AppAnotherTest.java:34)"; @Inject private JavaTestRunnerPluginConsole pluginConsole; diff --git a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/testrunner/JavaTestPluginTestNgTest.java b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/testrunner/JavaTestPluginTestNgTest.java index 7f610fcbbf6..6d29ba29260 100644 --- a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/testrunner/JavaTestPluginTestNgTest.java +++ b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/testrunner/JavaTestPluginTestNgTest.java @@ -50,10 +50,6 @@ public class JavaTestPluginTestNgTest { PROJECT + "/src/test/java/org/eclipse/che/examples/AppOneTest.java"; private static final String PATH_TO_ANOTHER_TEST_CLASS = PROJECT + "/src/test/java/org/eclipse/che/examples/AppAnotherTest.java"; - private static final String PATH_TO_MAIN_CLASS = - PROJECT + "/src/main/java/org/eclipse/che/examples/HelloWorld.java"; - private static final String PATH_TO_TEST_PACKAGE = - PROJECT + "/src/test/java/org/eclipse/che/examples"; public static final String APP_TEST_ONE_FAIL_OUTPUT_TEMPLATE = "[TestNG] Running: /home/user/che/ws-agent/temp/che-testng-suite.xmlexpected [false] but found [true]\n" From 41f149b7bcf53d784e6ee86c68f87f454ee5e204 Mon Sep 17 00:00:00 2001 From: Maxim Musienko Date: Thu, 28 Sep 2017 10:04:01 +0300 Subject: [PATCH 9/9] rework javadocs for methods (start with upper case), add autor to the test --- .../plugins/JavaTestRunnerPluginConsole.java | 22 +++++++++---------- ...uginJunit4CheckRunSuitesAndScopesTest.java | 1 + 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/pageobject/plugins/JavaTestRunnerPluginConsole.java b/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/pageobject/plugins/JavaTestRunnerPluginConsole.java index 64da7c0f6f2..37ae21a4860 100644 --- a/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/pageobject/plugins/JavaTestRunnerPluginConsole.java +++ b/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/pageobject/plugins/JavaTestRunnerPluginConsole.java @@ -92,7 +92,7 @@ public String getTestErrorMessage() { } /** - * wait single method in the result tree marked as failed (red color) + * Wait single method in the result tree marked as failed (red color). * * @param nameOfFailedMethods name of that should fail */ @@ -102,7 +102,7 @@ public void waitMethodMarkedAsFailed(String nameOfFailedMethods) { } /** - * wait single method in the result tree marked as failed (red color) + * Wait single method in the result tree marked as failed (red color). * * @param nameOfFailedMethods name of that should fail */ @@ -112,7 +112,7 @@ public void waitMethodMarkedAsIgnored(String nameOfFailedMethods) { } /** - * wait single method in the result tree marked as passed (green color) + * Wait single method in the result tree marked as passed (green color). * * @param nameOfFailedMethods name of expected method */ @@ -122,7 +122,7 @@ public void waitMethodMarkedAsPassed(String nameOfFailedMethods) { } /** - * wait the FQN of the test class in result tree class that has been launched + * Wait the FQN of the test class in result tree class that has been launched. * * @param fqn */ @@ -134,8 +134,8 @@ public void waitFqnOfTesClassInResultTree(String fqn) { } /** - * get all name of the test methods form the test result tree marked with defined status (may be - * passed, failed or ignored) + * Get all name of the test methods form the test result tree marked with defined status (may be + * passed, failed or ignored). * * @param methodState the enumeration with defined status * @return the list with names of methods with defined status @@ -157,7 +157,7 @@ public List getAllNamesOfMethodsMarkedDefinedStatus(JunitMethodsState me } /** - * get all defined methods from result tree and return as list WebElements + * Get all defined methods from result tree and return as list WebElements. * * @param methodState the enumeration with defined status * @return List WebElements with defined status @@ -187,7 +187,7 @@ private List getAllMetodsWithDefinedStatus(List definedMetho } /** - * get text from the test result tree. Mote! This method represent only text from test result tree + * Get text from the test result tree. Mote! This method represent only text from test result tree * without styles and formatting * * @return text representation of results of the test result tree widget @@ -199,8 +199,8 @@ public String getTextFromResultTree() { } /** - * click on the item in the result tree. If will be some items with the same name - will select - * first + * Click on the item in the result tree. If will be some items with the same name - will select + * first. * * @param item name of the item (method or fqn of test class) in the test result tree */ @@ -212,7 +212,7 @@ public void selectItemInResultTree(String item) { } /** - * click on faled, passed or ignored method on the result tree + * Click on faled, passed or ignored method on the result tree. * * @param nameOfMethod * @param state diff --git a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/testrunner/JavaTestPluginJunit4CheckRunSuitesAndScopesTest.java b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/testrunner/JavaTestPluginJunit4CheckRunSuitesAndScopesTest.java index a4a03752963..bf8f391d7ae 100644 --- a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/testrunner/JavaTestPluginJunit4CheckRunSuitesAndScopesTest.java +++ b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/testrunner/JavaTestPluginJunit4CheckRunSuitesAndScopesTest.java @@ -34,6 +34,7 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +/** @author Musienko Maxim */ public class JavaTestPluginJunit4CheckRunSuitesAndScopesTest { private static final String JUNIT4_PROJECT = "junit4-tests-with-separeted-suites";