Skip to content

Add selenium tests for covering advanced operations for C# LS#11261

Merged
musienko-maxim merged 16 commits intomasterfrom
CHE#11202
Sep 20, 2018
Merged

Add selenium tests for covering advanced operations for C# LS#11261
musienko-maxim merged 16 commits intomasterfrom
CHE#11202

Conversation

@musienko-maxim
Copy link
Copy Markdown
Contributor

What does this PR do?

  • Add new 4 tests for checking uncovered features like: hovering, autocommenting, find definition, go to symbol.

What issues does this PR fix or reference?

#11202

@musienko-maxim musienko-maxim changed the title Add selenium tests for covering advanced operations Add selenium tests for covering advanced operations for C# LS Sep 18, 2018
private static final String PROJECT_NAME =
NameGenerator.generate(CSharpClassRenamingTest.class.getSimpleName(), 4);

private static final String PATH_TO_DOTNET_FILE = PROJECT_NAME + "/Hello.cs";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about "PATH_TO_DOTNET_FILE" >>> "PATH_TO_DOT_NET_FILE"

String expectedTextInHoverPopUp =
"System.Console\nRepresents the standard input, output, and error streams for console applications. This class cannot be inherited.";
editor.moveCursorToText("Console");
Assert.assertEquals(editor.getTextFromHoverPopup(), expectedTextInHoverPopUp, "https://github.com/eclipse/che/issues/10117");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better change to "editor.waitTextInHoverPopup(expectedTextInHoverPopUp);" this increase stability of this test

Copy link
Copy Markdown
Contributor Author

@musienko-maxim musienko-maxim Sep 18, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

waitTextInHoverPopup does not work in this case because use this: seleniumWebDriverHelper.waitTextContains(hoverPopup, expectedText);. In this case check full text matching because text is duplicated.
Moreover editor.getTextFromHoverPopup() already had visibility waiting and pretty stable as for me

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case we could make both editor.waitTextInHoverPopupEqualsTo(expectedText) and editor.waitTextInHoverPopupContains(expectedText)

Copy link
Copy Markdown
Contributor

@Ohrimenko1988 Ohrimenko1988 Sep 18, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I understand, but you definitely will have a problem with this assert because it tries to get text exactly once and if something doesn't display, test will be failed.
What about adding a new method to page object with "SeleniumWebDriverHelper#waitTextEqualsTo"

public void checkFindDefinition() {
editor.goToCursorPositionVisible(21, 18);
menu.runCommand(ASSISTANT, FIND_DEFINITION);
editor.waitTabFileWithSavedStatus("Test.cs");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you mean "editor.waitTabIsPresent("Test.cs");"?


@Test(priority = 3, alwaysRun = true)
public void checkGoToSymbolFeature() {
menu.runCommand(ASSISTANT, FIND_DEFINITION);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

menu.runCommand(ASSISTANT, FIND_DEFINITION); -> menu.runCommand(ASSISTANT, GO_TO_SYMBOL);

@Test(priority = 2, alwaysRun = true)
public void checkCodeCommentFeature() {
editor.goToPosition(17, 1);
editor.typeTextIntoEditor(CONTROL.toString() + "/");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I know it doesn't work. Please change to:

String comment = Keys.chord(CONTROL, "/");
seleniumWebDriverHelper.sendKeys(comment);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't work where? More details please.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you test this? If it works then OK.

Copy link
Copy Markdown
Contributor Author

@musienko-maxim musienko-maxim Sep 18, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it works in my case in grid and local mode

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would recommend to use existed method CodenvyEditor#launchCommentCodeFeature() to comment the line.

String expectedTextInHoverPopUp =
"System.Console\nRepresents the standard input, output, and error streams for console applications. This class cannot be inherited.";
editor.moveCursorToText("Console");
Assert.assertEquals(editor.getTextFromHoverPopup(), expectedTextInHoverPopUp, "https://github.com/eclipse/che/issues/10117");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also I would make error message clearer, like the follow:

Known random failure https://github.com/eclipse/che/issues/10117


@Test(priority = 1, alwaysRun = true)
public void checkFindDefinition() {
editor.goToCursorPositionVisible(21, 18);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you, please, comment, which which thing we are trying to find definition of here?

@benoitf benoitf added status/code-review This issue has a pull request posted for it and is awaiting code review completion by the community. kind/task Internal things, technical debt, and to-do tasks to be performed. labels Sep 18, 2018
return seleniumWebDriverHelper.waitVisibilityAndGetText(hoverPopup);
}

/** Get text from hover popup */
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/** Get text from hover popup / --> /* Wait text from hover popup*/


@BeforeClass
public void setUp() throws Exception {
URL resource = getClass().getResource("/projects/CSharpFileAdvancedOperations");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you, please, comment on what we are trying to achieve here?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my opinion, just renaming of variable to something like "testProject" will be enough.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant setUp() method itself - what it is actually setting up?

Copy link
Copy Markdown
Contributor Author

@musienko-maxim musienko-maxim Sep 19, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor

@dmytro-ndp dmytro-ndp Sep 19, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, I am talking about state of IDE which we are achieving after the method is executed.
According to the code, I would write that the method "is opening PATH_TO_DOTNET_FILE, then waits initialization of Language Server, and then waits until "/obj" and "/bin" directories are visible in ProjectExplorer".

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, i have understood now. So i've added comment, check it please

String expectedTextInHoverPopUp =
"System.Console\nRepresents the standard input, output, and error streams for console applications. This class cannot be inherited.";
editor.moveCursorToText("Console");
Assert.assertEquals(editor.getTextFromHoverPopup(), expectedTextInHoverPopUp, "https://github.com/eclipse/che/issues/10117");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case we could make both editor.waitTextInHoverPopupEqualsTo(expectedText) and editor.waitTextInHoverPopupContains(expectedText)

seleniumWebDriverHelper.waitTextEqualsTo(hoverPopup, expectedText);
} catch (TimeoutException ex) {
// remove try-catch block after issue has been resolved
fail("Known issue https://github.com/eclipse/che/issues/10117", ex);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you happen to know if it is permanent or random failure?

@musienko-maxim
Copy link
Copy Markdown
Contributor Author

ci-build

@musienko-maxim
Copy link
Copy Markdown
Contributor Author

ci-build

@musienko-maxim musienko-maxim merged commit b5ceb99 into master Sep 20, 2018
@benoitf benoitf added this to the 6.12.0 milestone Sep 20, 2018
@benoitf benoitf removed the status/code-review This issue has a pull request posted for it and is awaiting code review completion by the community. label Sep 20, 2018
@musienko-maxim musienko-maxim deleted the CHE#11202 branch September 20, 2018 12:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/task Internal things, technical debt, and to-do tasks to be performed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants