Skip to content

Commit

Permalink
Sample updates
Browse files Browse the repository at this point in the history
  • Loading branch information
wakaleo committed May 18, 2024
1 parent 0717bcb commit 17254c1
Show file tree
Hide file tree
Showing 14 changed files with 72 additions and 11 deletions.
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.1.3</serenity.version>
<serenity.version>4.1.12</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
@@ -1,7 +1,9 @@
package net.serenitybdd.demos.todos.screenplay.questions;

import net.serenitybdd.demos.todos.screenplay.user_interface.TodoList;
import net.serenitybdd.screenplay.Actor;
import net.serenitybdd.screenplay.Question;
import net.serenitybdd.screenplay.ensure.Ensure;
import net.serenitybdd.screenplay.questions.Text;

import java.util.Collection;
Expand All @@ -20,4 +22,14 @@ public static Question<Integer> leftCount() {
.describedAs("the number of items left")
.asInteger();
}

public static Question<Integer> left() {
return actor -> {
actor.attemptsTo(
Ensure.that("a").isEqualTo("b")
);
return 1;
};
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
@IncludeEngines("cucumber")
@SelectClasspathResource("/features")
@ConfigurationParameter(key = GLUE_PROPERTY_NAME, value = "net.serenitybdd.demos.todos.cucumber.steps")
@ConfigurationParameter(key = FILTER_TAGS_PROPERTY_NAME, value = "not @ignore")
//@ConfigurationParameter(key = FILTER_TAGS_PROPERTY_NAME, value = "@smoke-test and @filtering")
public class CucumberTestSuite {
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,21 @@ public void sheFiltersTheListToShowOnlyFilterTasks(String status) {
public void herListShouldContain(List<String> items) {
james.should_see_that_displayed_items_contain(items.toArray(new String[]{}));
}

@Given("Pete wants to change his password")
public void peteWantsToChangeHisPassword() {
}

@When("he enters {string} as his new password")
public void heEntersAsHisNewPassword(String arg0) {
}

@Then("his password should be updated")
public void hisPasswordShouldBeUpdated() {
}

@Then("his password should be updated:{}")
public void hisPasswordShouldBeUpdatedUpdated(boolean yes) {

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import io.cucumber.java.en.Given;
import io.cucumber.java.en.Then;
import io.cucumber.java.en.When;
import net.serenitybdd.core.Serenity;
import net.serenitybdd.core.annotations.events.AfterExample;
import net.serenitybdd.demos.todos.cucumber.MissingTodoItemsException;
import net.serenitybdd.demos.todos.screenplay.model.TodoStatus;
Expand Down Expand Up @@ -81,6 +82,7 @@ public void that_James_has_an_empty_todo_list(Actor actor) {

@Given("{actor} has a todo list containing {items}")
public void that_James_has_an_empty_todo_list(Actor actor, List<String> items) {
Serenity.setSessionVariable("todoItems").to(items);
actor.wasAbleTo(Start.withATodoListContaining(items));
}

Expand Down Expand Up @@ -127,6 +129,9 @@ public void item_should_be_recorded_in_the_list(String expectedItem) {

@Then("his/her todo list should contain {items}")
public void todo_list_should_contain(List<String> expectedItems) {
List<String> originalItems = Serenity.sessionVariableCalled("todoItems");
assertThat(originalItems).isNotEmpty();

theActorInTheSpotlight().should(seeThat(TheItems.displayed(), equalTo(expectedItems))
.orComplainWith(MissingTodoItemsException.class, "Missing todos " + expectedItems));
}
Expand All @@ -151,4 +156,8 @@ public void filters_tasks_by(Actor actor, TodoStatusFilter status) {
FilterItems.toShow(status)
);
}

@Then("his password should be updated:<updated?>")
public void hisPasswordShouldBeUpdatedUpdated() {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ public void should_be_able_to_complete_a_todo_using_a_bdd_style() {
);
then(james).should(
seeThat(TheItemStatus.forTheItemCalled("Walk the dog"), is(Completed)),
seeThat(TheItems.leftCount(), is(1))
// seeThat(TheItems.leftCount(), is(1))
seeThat(TheItems.left(), is(1))
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

@ExtendWith(SerenityJUnit5Extension.class)
@Tag("Screenplay")
public class ClearCompletedTodos {
public class ClearCompletedTodoItems {

@Managed private WebDriver hisBrowser;
private Actor james = Actor.named("James");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

@ExtendWith(SerenityJUnit5Extension.class)
@Tag("Screenplay")
public class DeletingTodos {
public class DeletingTodoItems {

@Managed
private WebDriver hisBrowser;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import net.serenitybdd.screenplay.Actor;
import net.serenitybdd.screenplay.abilities.BrowseTheWeb;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
Expand All @@ -19,7 +20,6 @@
import org.junit.jupiter.params.provider.MethodSource;
import org.openqa.selenium.WebDriver;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Stream;

Expand All @@ -30,7 +30,7 @@

@ExtendWith(SerenityJUnit5Extension.class)
@Tag("Screenplay")
public class FilteringTodos {
public class FilteringTodoItems {

private Actor james = Actor.named("James");
@Managed private WebDriver hisBrowser;
Expand Down Expand Up @@ -71,6 +71,7 @@ public void should_be_able_to_view_only_incomplete_todos() {

@ParameterizedTest
@MethodSource("todoTestData")
@DisplayName("Foo bar")
public void should_be_able_to_view_various_todo_combinations(String completeItem,
String incompleteItem,
TodoStatusFilter filterOption,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

@ExtendWith(SerenityJUnit5Extension.class)
@Tag("Screenplay")
public class TodosBelongToAUser {
public class HandlingTodosBelongingToSeveralUsers {

private Actor james = Actor.named("James");
private Actor jane = Actor.named("Jane");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,31 @@ Feature: Completing todos
As a forgetful person
I want to be to _view all of things I have completed_

@smoke-test
Scenario: When a task is completed it remains in the main list
Given Jane has a todo list containing Buy some milk, Walk the dog
When she completes the task called "Walk the dog"
Then her todo list should contain Buy some milk, Walk the dog
But the "Walk the dog" task should be shown as Completed

Given Pete wants to change his password
When he enters "Password1!" as his new password
Then his password should be updated

@manual
Scenario Outline: Updating a password
Given Pete wants to change his password
When he enters "<password>" as his new password
Then his password should be updated:<updated?>
Examples:
| password | updated? |
| Password1! | true |
| Password1 | false |
| Password! | false |
| Passwor | false |


@ios
Scenario: Completed tasks should appear in the Completed list
Given Jane has a todo list containing Buy some milk, Walk the dog
When she completes the task called "Walk the dog"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ Feature: Deleting todos
As a tidy person
I want to be to delete the tasks once I am done with them

@smoke-test
Scenario: Delete an active item
Given Jane has a todo list containing Buy some milk, Walk the dog
When she deletes the task called 'Walk the dog'
Then her todo list should contain Buy some milk

@manual
Scenario: Delete all the items
Given Jane has a todo list containing Buy some milk, Walk the dog
When she deletes the task called 'Walk the dog'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Feature: Filtering other todos
As a forgetful person
I want to be to view all of things I have completed

@ios @android
Scenario Outline: Filtering items by status
Given Jane has prepared a todo list containing <tasks>
And she has completed the task called "<completed>"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
@cucumber
@filtering
@smoke-test
Feature: Filtering 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: Viewing the items by status
Scenario Outline: Viewing the items by status filter
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 | 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 |

0 comments on commit 17254c1

Please sign in to comment.