Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Fekete Bernadett PR: ui+performance tests #19

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions .classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
/target/
23 changes: 23 additions & 0 deletions .project
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>sapi2020test</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>
8 changes: 8 additions & 0 deletions .settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
org.eclipse.jdt.core.compiler.compliance=1.5
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.5
522 changes: 522 additions & 0 deletions SCRUM performance test.jmx

Large diffs are not rendered by default.

57 changes: 34 additions & 23 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,38 @@
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.45.0</version>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-java</artifactId>
<version>1.1.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-junit</artifactId>
<version>1.1.2</version>
<scope>test</scope>
</dependency>
</dependencies>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.141.59</version>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-java</artifactId>
<version>1.2.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-junit</artifactId>
<version>1.2.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-firefox-driver</artifactId>
<version>3.141.59</version>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-picocontainer</artifactId>
<version>1.2.5</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
package ro.sapientia.mesteri2015.test;

import java.util.List;
import java.util.concurrent.TimeUnit;

import org.junit.Assert;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;

import cucumber.api.java.After;
import cucumber.api.java.Before;
import cucumber.api.java.en.Given;
import cucumber.api.java.en.Then;
import cucumber.api.java.en.When;

public class SCRUMCommentStepDefinition {

protected WebDriver driver;

@Before
public void setup() {
driver = new FirefoxDriver();
}

@After
public void closeBrowser() {
driver.quit();
}

@When("^I click on \"([^\"]*)\" button$")
public void i_press_button(String buttonId) throws Throwable {
WebElement button = driver.findElement(By.id(buttonId));
button.click();
}

@When("^I enter \"([^\"]*)\" in the \"([^\"]*)\" textbox$")
public void i_enter_in_the_textbox(String inputText, String textBoxId) throws Throwable {
WebElement textBox = driver.findElement(By.id(textBoxId));
textBox.clear();
textBox.sendKeys(inputText);
}

@Then("^I should see (\\d+)x \"([^\"]*)\" in the story's comment list$")
public void i_should_see_x_in_the_story_s_comment_list(int expectedCount, String commentMessage) throws Throwable {
List<WebElement> comments = driver
.findElements(By.xpath("//p[@class='comment-message' and normalize-space()='" + commentMessage + "']"));
Assert.assertEquals(expectedCount, comments.size());
}

@Then("^I should see an error$")
public void i_should_see_an_error() throws Throwable {
WebElement error = driver.findElement(By.id("error-title"));
}

@When("^I delete the comment with \"([^\"]*)\" message$")
public void i_delete_the_comment_with_message(String commentMessage) throws Throwable {
WebElement deleteButton = driver.findElement(By.xpath("//p[@class='comment-message' and normalize-space()='"
+ commentMessage + "']//following::a[@id='delete-comment-link']"));
deleteButton.click();

WebElement confirmationDeleteButton = driver.findElement(By.id("delete-comment-button"));
confirmationDeleteButton.click();
}

@Then("^I see that comments sections states \"([^\"]*)\"$")
public void i_see_that_comments_sections_states(String expectedEmptyMessage) throws Throwable {
WebElement emptyMessage = driver
.findElement(By.xpath("//div[@id='comment-list']/p[normalize-space()='There are no comments yet.']"));
Assert.assertNotNull(emptyMessage);
}

@Then("^comment list contains (\\d+)x comments$")
public void comment_list_contains_x_comments(int expectedCount) throws Throwable {
List<WebElement> comments = driver
.findElements(By.xpath("//div[@id='comment-list']/div[contains(@class, 'comment-item')]"));
Assert.assertEquals(expectedCount, comments.size());
}

@Given("^I am on the view page of a new story called \"([^\"]*)\" with (\\d+)x comment$")
public void i_am_on_the_view_page_of_a_new_story_called_with_x_comment(String storyName, int nrOfComments)
throws Throwable {
driver.get("http://localhost:8080/");

WebElement addLink = driver.findElement(By.id("add-button"));
addLink.click();

WebElement titleTextBox = driver.findElement(By.id("story-title"));
titleTextBox.clear();
titleTextBox.sendKeys(storyName);

WebElement addButton = driver.findElement(By.id("add-story-button"));
addButton.click();

for (int i = 1; i <= nrOfComments; i++) {
WebElement addCommentLink = driver.findElement(By.id("add-button"));
addCommentLink.click();

WebElement commentTextBox = driver.findElement(By.id("comment-message"));
commentTextBox.clear();
commentTextBox.sendKeys(storyName + "Comment " + i);

WebElement addCommentButton = driver.findElement(By.id("add-comment-button"));
addCommentButton.click();
}
}

@Then("^I should see \"([^\"]*)\" story's view page$")
public void i_should_see_story_s_view_page(String storyName) throws Throwable {
WebElement titleText = driver.findElement(By.id("story-title"));
String result = titleText.getText();

Assert.assertEquals(result, storyName);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import org.junit.Assert;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.By;
Expand All @@ -24,6 +25,12 @@ public void setup() {
driver = new FirefoxDriver();
}

@After
public void closeBrowser() {
driver.quit();
}


@Given("^I edit the scrum list's first story$")
public void I_edit_the_scrum_list_s_first_story() throws Throwable {
// Express the Regexp above with the code you wish you had
Expand All @@ -44,12 +51,12 @@ public void I_enter_in_the_title_textbox_and_I_push_the_update_button(String upd
titleField.sendKeys(Keys.CONTROL + "a");
titleField.sendKeys(Keys.DELETE);
titleField.sendKeys(updateTitle);

WebElement updateStoryButton = driver.findElement(By.id("update-story-button"));
updateStoryButton.click();

}

@Then("^I should get result \"([^\"]*)\" in new stories list$")
public void I_should_get_result_in_new_stories_list(String expectedResult) throws Throwable {
// Express the Regexp above with the code you wish you had
Expand All @@ -59,12 +66,5 @@ public void I_should_get_result_in_new_stories_list(String expectedResult) throw
// Verify that result of 2+2 is 4
Assert.assertEquals(result, expectedResult);
//Assert.assertNotSame(result, expectedResult);
driver.close();
}

@After
public void closeBrowser() {
driver.quit();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
import org.junit.Assert;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.By;

import cucumber.api.java.After;
Expand All @@ -23,16 +25,20 @@ public void setup() {
driver = new FirefoxDriver();
}

@Given("^I open the scrum tool add page$")
public void I_open_the_scrum_tool_add_page() throws Throwable {
@After
public void closeBrowser() {
driver.quit();
}

@Given("^I open the scrum tool$")
public void I_open_the_scrum_tool() throws Throwable {
// Set implicit wait of 10 seconds and launch google
driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
driver.get("http://localhost:8080/");
}

@When("^I enter \"([^\"]*)\" in the title textbox and I push the add button$")
public void I_enter_in_the_title_textbox_and_I_push_the_add_button(
String additionTerms) throws Throwable {
@When("^I access the add story page and enter \"([^\"]*)\" in the title textbox and I push the add button$")
public void I_access_the_add_story_page_and_enter_in_the_title_textbox_and_i_push_the_add_button(String additionTerms) throws Throwable {
WebElement addButton = driver.findElement(By.id("add-button"));
addButton.click();

Expand All @@ -47,20 +53,12 @@ public void I_enter_in_the_title_textbox_and_I_push_the_add_button(
}

@Then("^I should get result \"([^\"]*)\" in stories list$")
public void I_should_get_result_in_stories_list(String expectedResult)
throws Throwable {
public void I_should_get_result_in_stories_list(String expectedResult) throws Throwable {
WebElement calculatorTextBox = driver.findElement(By.id("story-title"));
String result = calculatorTextBox.getText();

// Verify that result of 2+2 is 4
Assert.assertEquals(result, expectedResult);

driver.close();
}

@After
public void closeBrowser() {
driver.quit();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ Feature: Check if the scrum story add
As Sapientia scrum tool user I want to be able to add stories

Scenario: Title1
Given I open the scrum tool add page
When I enter "title1" in the title textbox and I push the add button
Given I open the scrum tool
When I access the add story page and enter "title1" in the title textbox and I push the add button
Then I should get result "title1" in stories list
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ Feature: Check if the scrum update works
Scenario: UpdateFirst
Given I edit the scrum list's first story
When I enter "updatefirstnew" in the title textbox and I push the update button
Then I should get result "updatefirstnew" in new stories list
Then I should get result "updatefirstnew" in new stories list
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
@Comment
Feature: Adding incorrect comments displays error
A sapientia scrum tool user wants to add comments safely, so input data is validated and a proper error is presented to the user.

Scenario: Adding empty comments should show an error message
Given I am on the view page of a new story called "Adding empty comments" with 0x comment
When I click on "add-button" button
And I enter "" in the "comment-message" textbox
And I click on "add-comment-button" button
Then I should see an error

Loading