Skip to content

Commit

Permalink
Increased parallel execution
Browse files Browse the repository at this point in the history
  • Loading branch information
wakaleo committed Jan 23, 2024
1 parent acfc326 commit b91ff63
Show file tree
Hide file tree
Showing 17 changed files with 102 additions and 55 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ the [PageObject](http://martinfowler.com/bliki/PageObject.html)
and the [Screenplay pattern](https://dzone.com/articles/page-objects-refactored-solid-steps-to-the-screenp),
both implemented using the [Serenity BDD](http://serenity-bdd.info/#/) library and JUnit.

The web tests you'll find here run against the http://todomvc.com/examples/angularjs/#/ application and are organised
The web tests you'll find here run against the https://todomvc.com/examples/angular/dist/browser/#/all application and are organised
by feature in packages under `src/test/java/net/serenitybdd/demos/todos/<pattern name>/features`.

By default the tests run on Chrome, so make sure you have the latest chromedriver instance on your system path.
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<serenity.version>4.0.43</serenity.version>
<serenity.version>4.0.44</serenity.version>
<encoding>UTF-8</encoding>
<serenity.test.root></serenity.test.root>
<tags></tags>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;

@DefaultUrl("http://todomvc.com/examples/angularjs/#/")
@DefaultUrl("https://todomvc.com/examples/angular/dist/browser/#/all")
public class TodoListPage extends PageObject {

// -----------------------------------------------------------------------------------------------------------------
Expand All @@ -26,12 +26,12 @@ public class TodoListPage extends PageObject {
private static final String NEW_TODO_INPUT_FIELD = ".new-todo";
private static final String ITEM_ROW = "//div[@class='view' and contains(.,'%s')]";
private static final String ITEM_ROW_LABEL = "//label[contains(.,'%s')]";
private static final String COMPLETE_TICKBOX = ".//input[@ng-model='todo.completed']";
private static final String COMPLETE_TICKBOX = ".toggle";
private static final String DELETE_BUTTON = "//button[@class='destroy']";
private static final String FILTERS = ".filters";
private static final String SELECTED_FILTER = ".filters li .selected";
private static final String ITEMS_LEFT_COUNT = ".todo-count strong";
private static final String TOGGLE_ALL = "#toggle-all";
private static final String TOGGLE_ALL = ".toggle-all";
private static final String CLEAR_COMPLETED = ".clear-completed";

// -----------------------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -98,7 +98,7 @@ public void clearCompletedItems() {
}

public void toggleAll() {
evaluateJavascript("arguments[0].click();",$("#toggle-all"), $(TOGGLE_ALL));
evaluateJavascript("arguments[0].click();",$(".toggle-all"), $(TOGGLE_ALL));
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,17 +136,12 @@ public void should_see_that_displayed_items_do_not_contain(String... items) {

@Step
public void should_see_the_correct_website_title() {
assertThat(todoListPage.getTitle(), is("AngularJS • TodoMVC"));
assertThat(todoListPage.getTitle(), is("TodoMVC: Angular"));
}

@Step
public void should_see_the_correct_application_heading() {
assertThat(todoListPage.heading(), is("todos"));
}

@Step
public void should_see_the_about_section() {
assertThat(todoListPage.footer(), containsString("Credits"));
assertThat(todoListPage.heading(), is("Todos"));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import java.util.Arrays;
import java.util.List;

import static org.assertj.core.api.Assertions.assertThat;

public class Start {

public static Performable withAnEmptyTodoList() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ public class TodoList {
public static final Target ITEMS = Target.the("List of todo items").locatedBy(".view label");
public static final Target ITEMS_LEFT = Target.the("Count of items left").locatedBy(".todo-count strong");
public static final Target TOGGLE_ALL_LABEL = Target.the("Toggle all items").locatedBy("[for='toggle-all']");
public static final Target TOGGLE_ALL_BUTTON = Target.the("Toggle all items link").locatedBy("#toggle-all");
public static final Target TOGGLE_ALL_BUTTON = Target.the("Toggle all items link").locatedBy(".toggle-all");
public static final Target CLEAR_COMPLETED = Target.the("Clear completed link").locatedBy(".clear-completed");
public static final Target FILTER = Target.the("filter by {0}").locatedBy("//a[.='{0}']");
public static final Target SELECTED_FILTER = Target.the("selected filter").locatedBy(".filters li .selected");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package net.serenitybdd.demos.todos.cucumber.steps;

import io.cucumber.java.en.And;
import io.cucumber.java.en.Given;
import io.cucumber.java.en.Then;
import io.cucumber.java.en.When;
import net.serenitybdd.annotations.Steps;
import net.serenitybdd.demos.todos.pageobjects.model.TodoStatusFilter;
import net.serenitybdd.demos.todos.pageobjects.steps.TodoUserSteps;
import net.serenitybdd.screenplay.Actor;

import java.util.List;

public class TodoUserActionSteps {

@Steps
TodoUserSteps james;

@Given("Jane has prepared a todo list containing {items}")
public void that_James_has_an_empty_todo_list(List<String> items) {
james.starts_with_a_todo_list_containing(items.toArray(new String[]{}));
}

@And("he/she has completed the task called {string}")
public void sheHasCompletedTheTaskCalled(String task) {
james.completes(task);
}

@When("she filters the list to show only {} tasks")
public void sheFiltersTheListToShowOnlyFilterTasks(String status) {
james.filters_items_to_show(TodoStatusFilter.valueOf(status));
}

@Then("her list should contain {items}")
public void herListShouldContain(List<String> items) {
james.should_see_that_displayed_items_contain(items.toArray(new String[]{}));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import net.serenitybdd.screenplay.actors.OnStage;
import net.serenitybdd.screenplay.actors.OnlineCast;
import net.serenitybdd.screenplay.ensure.Ensure;
import net.serenitybdd.screenplay.matchers.WebElementStateMatchers;
import net.serenitybdd.screenplay.ui.Button;
import net.serenitybdd.screenplay.waits.Wait;

import java.util.List;
Expand All @@ -29,6 +31,8 @@
import static net.serenitybdd.screenplay.GivenWhenThen.seeThat;
import static net.serenitybdd.screenplay.actors.OnStage.setTheStage;
import static net.serenitybdd.screenplay.actors.OnStage.theActorInTheSpotlight;
import static net.serenitybdd.screenplay.matchers.WebElementStateMatchers.isEnabled;
import static net.serenitybdd.screenplay.questions.WebElementQuestion.the;
import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.Matchers.*;

Expand Down Expand Up @@ -129,14 +133,13 @@ public void todo_list_should_contain(List<String> expectedItems) {

@Then("{actor}'s todo list should contain {items}")
public void a_users_todo_list_should_contain(Actor actor, List<String> expectedItems) {

actor.attemptsTo(
Wait.until(TheItems.displayed(), is(not(empty()))),
Wait.until(TheItems.displayed(), is(not(empty()))).forNoMoreThan(5).seconds(),
Ensure.that(TheItems.displayed()).containsElementsFrom(expectedItems)
.withReportedError("Missing todos " + expectedItems)
);
}


@Then("his/her todo list should be empty")
public void todo_list_should_be_empty() {
theActorInTheSpotlight().should(seeThat(TheItems.displayed(), equalTo(EMPTY_LIST)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ public void should_be_able_to_identify_the_application_with_page_objects() {

james.should_see_the_correct_website_title();
james.should_see_the_correct_application_heading();
james.should_see_the_about_section();
}

@Test
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,8 @@ public void should_be_able_to_identify_the_application() {

then(james).should(
seeThat(Application.information(),
displays("title",equalTo("AngularJS • TodoMVC")),
displays("heading",equalTo("todos")),
displays("about", containsString("Credits"))
displays("title",equalTo("TodoMVC: Angular")),
displays("heading",equalTo("Todos"))
)
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public void jamesCanBrowseTheWeb() {

@Test
public void should_be_able_to_complete_a_todo_using_imperative_code() {
driver.get("http://todomvc.com/examples/angularjs/#/");
driver.get("https://todomvc.com/examples/angular/dist/browser/#/all");
driver.findElement(By.cssSelector(".new-todo")).sendKeys("Walk the dog", Keys.ENTER);
driver.findElement(By.cssSelector(".new-todo")).sendKeys("Put out the garbage", Keys.ENTER);
driver.findElement(
Expand Down Expand Up @@ -77,7 +77,7 @@ private TodoMVC(WebDriver driver) {
}

public void open() {
driver.get("http://todomvc.com/examples/angularjs/#/");
driver.get("https://todomvc.com/examples/angular/dist/browser/#/all");
}

public void enterTodoField(String todoName) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@ Feature: Completing todos
Then her todo list should contain Walk the dog

Scenario Outline: Completed tasks should be shown as Completed
Given Jane has a todo list containing Buy some milk, Walk the dog
Given Jane has a todo list containing <Initial Tasks>
When she completes the task called "Walk the dog"
Then the "<Task>" task should be shown as <Final Status>
Examples:
| Task | Final Status |
| Walk the dog | Completed |
| Buy some milk | Active |
| Initial Tasks | Task | Final Status |
# | | Walk the dog | Completed |
| Buy some milk, Walk the dog | Walk the dog | Completed |
| Walk the dog | Walk the dog | Completed |
| Buy some milk, Walk the dog | Buy some milk | Active |

Scenario: The list of completed items should be empty if nothing has been completed
Given Jane has a todo list containing Buy some milk, Walk the dog
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
@cucumber
@filtering
Feature: Filtering other todos

In order to make me feel a sense of accomplishment
As a forgetful person
I want to be to view all of things I have completed

Scenario Outline: Filtering items by status
Given Jane has prepared a todo list containing <tasks>
And she has completed the task called "<completed>"
When she filters the list to show only <filter> tasks
Then her list should contain <expected>
Examples:
| tasks | completed | filter | expected |
| Buy some milk, Walk the dog | Walk the dog | Active | Buy some milk |
# | Buy some milk, Walk the dog | Broken | Active | Buy some milk |
| Buy some milk, Walk the dog | Walk the dog | Completed | Walk the dog |
| Buy some milk, Walk the dog | Walk the dog | All | Buy some milk, Walk the dog |
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ Feature: Filtering todos
I want to be to view all of things I have completed

Scenario Outline: Viewing the items by status
Given Jane has a todo list containing <tasks>
And she completes the task called "Walk the dog"
Given Jane has a todo list containing <tasks>
And she completes the task called "<completed>"
When she filters her list to show only <filter> tasks
Then her todo list should contain <expected>
Examples:
| tasks | filter | expected |
| Buy some milk, Walk the dog | Active | Buy some milk |
| Buy some milk, Walk the dog | Completed | Walk the dog |
| Buy some milk, Walk the dog | All | Buy some milk, Walk the dog |
| tasks | completed | filter | expected |
| Buy some milk, Walk the dog | Walk the dog | Active | Buy some milk |
# | Buy some milk, Walk the dog | Broken | Active | Buy some milk |
| Buy some milk, Walk the dog | Walk the dog | Completed | Walk the dog |
| Buy some milk, Walk the dog | Walk the dog | All | Buy some milk, Walk the dog |
8 changes: 4 additions & 4 deletions src/test/resources/junit-platform.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ junit.jupiter.execution.parallel.enabled=true
junit.jupiter.execution.parallel.config.strategy=fixed
junit.jupiter.execution.parallel.mode.default = concurrent
junit.jupiter.execution.parallel.mode.classes.default = concurrent
junit.jupiter.execution.parallel.config.fixed.parallelism=5
junit.jupiter.execution.parallel.config.fixed.max-pool-size=5
junit.jupiter.execution.parallel.config.fixed.parallelism=10
junit.jupiter.execution.parallel.config.fixed.max-pool-size=10

#
# Required to run Serenity Cucumber tests with JUnit 5 if you don't define this plugin in your runner class
Expand Down Expand Up @@ -33,8 +33,8 @@ junit.jupiter.execution.parallel.config.fixed.max-pool-size=5
#----------------------------------------------------------
cucumber.execution.parallel.enabled=true
cucumber.execution.parallel.config.strategy=fixed
cucumber.execution.parallel.config.fixed.parallelism=5
cucumber.execution.parallel.config.fixed.max-pool-size=5
cucumber.execution.parallel.config.fixed.parallelism=10
cucumber.execution.parallel.config.fixed.max-pool-size=10
cucumber.plugin=io.cucumber.core.plugin.SerenityReporterParallel,pretty,timeline:target/test-results/timeline


12 changes: 6 additions & 6 deletions src/test/resources/serenity.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
webdriver {
base.url = "http://todomvc.com/examples/angularjs/#/"
base.url = "https://todomvc.com/examples/angular/dist/browser/#/all"
driver = chrome
capabilities {
browserName = "chrome"
Expand Down Expand Up @@ -33,15 +33,15 @@ serenity {
}

// Default page configuration
home.page = "http://todomvc.com/examples/angularjs/#/"
home.page = "https://todomvc.com/examples/angular/dist/browser/#/all"

environment = "prod,chrome"
environments {
local {
home.page = "http://localhost:8080/angularjs/#/"
}
prod {
home.page = "http://todomvc.com/examples/angularjs/#/"
home.page = "https://todomvc.com/examples/angular/dist/browser/#/all"
}
chrome {
webdriver {
Expand Down Expand Up @@ -87,7 +87,7 @@ environments {
}
}
browserstack {
home.page = "http://todomvc.com/examples/angularjs/#/"
home.page = "https://todomvc.com/examples/angular/dist/browser/#/all"
webdriver {
driver = "remote"
remote.url = "https://"${BROWSERSTACK_USER}":"${BROWSERSTACK_KEY}"@hub.browserstack.com/wd/hub"
Expand All @@ -110,7 +110,7 @@ environments {
}
}
saucelabs {
home.page = "http://todomvc.com/examples/angularjs/#/"
home.page = "https://todomvc.com/examples/angular/dist/browser/#/all"
webdriver {
driver = "remote"
remote.url = "https://"${SAUCE_USERNAME}":"${SAUCE_ACCESS_KEY}"@ondemand.us-west-1.saucelabs.com:443/wd/hub"
Expand All @@ -128,7 +128,7 @@ environments {
}
}
lambdatest {
home.page = "http://todomvc.com/examples/angularjs/#/"
home.page = "https://todomvc.com/examples/angular/dist/browser/#/all"
webdriver {
driver = remote
remote.url = "https://"${LT_USERNAME}":"${LT_ACCESS_KEY}"@hub.lambdatest.com/wd/hub"
Expand Down

0 comments on commit b91ff63

Please sign in to comment.