serenity bdd - from executable specifications to living documentation
TRANSCRIPT
![Page 1: Serenity BDD - from executable specifications to living documentation](https://reader033.vdocuments.site/reader033/viewer/2022051520/58ed9af51a28ab75278b46e5/html5/thumbnails/1.jpg)
@wakaleo
The evolution of automated testing practicesTake me on a journey
@wakaleo
![Page 2: Serenity BDD - from executable specifications to living documentation](https://reader033.vdocuments.site/reader033/viewer/2022051520/58ed9af51a28ab75278b46e5/html5/thumbnails/2.jpg)
@wakaleo
John Ferguson
Smart
Introductions
“I help teams of smart people learn to work together more efficiently,
to deliver better software faster”
![Page 3: Serenity BDD - from executable specifications to living documentation](https://reader033.vdocuments.site/reader033/viewer/2022051520/58ed9af51a28ab75278b46e5/html5/thumbnails/3.jpg)
Alex Soto Bueno
Introductions
“I like helping open source projects, Java EE advocate and father of 2 girls”
![Page 4: Serenity BDD - from executable specifications to living documentation](https://reader033.vdocuments.site/reader033/viewer/2022051520/58ed9af51a28ab75278b46e5/html5/thumbnails/4.jpg)
@wakaleo
Test AutomationDo it well, or don’t do it at all
![Page 5: Serenity BDD - from executable specifications to living documentation](https://reader033.vdocuments.site/reader033/viewer/2022051520/58ed9af51a28ab75278b46e5/html5/thumbnails/5.jpg)
@wakaleo
Narrative Coding Style
Open-Closed Principle
Single Responsibility Principle
Separation of Concerns
Software Engineering Principles can help you write more maintainable tests
![Page 6: Serenity BDD - from executable specifications to living documentation](https://reader033.vdocuments.site/reader033/viewer/2022051520/58ed9af51a28ab75278b46e5/html5/thumbnails/6.jpg)
@wakaleo
Separation of Concerns - Layers
Goals
Tasks
Actions
What are you trying to achieve?
What do you need to do to achieve this goal?
What interactions with the system do you need for each
task?
![Page 7: Serenity BDD - from executable specifications to living documentation](https://reader033.vdocuments.site/reader033/viewer/2022051520/58ed9af51a28ab75278b46e5/html5/thumbnails/7.jpg)
@wakaleo
Separation of Concerns - Layers
Scenario: Add a new todo entry on the todo home page Given I am on the Todo application home page When I enter 'Buy some milk' into the New Todo field And I press ENTER Then the todo list box should contain 'Buy some milk'
![Page 8: Serenity BDD - from executable specifications to living documentation](https://reader033.vdocuments.site/reader033/viewer/2022051520/58ed9af51a28ab75278b46e5/html5/thumbnails/8.jpg)
@wakaleo
Separation of Concerns - Layers
Scenario: Record a new todo action for future use Given I need to buy some milk When I add the todo action 'Buy some milk' Then 'Buy some milk' should be recorded in my todo list
![Page 9: Serenity BDD - from executable specifications to living documentation](https://reader033.vdocuments.site/reader033/viewer/2022051520/58ed9af51a28ab75278b46e5/html5/thumbnails/9.jpg)
@wakaleo
Feature documentationDetailed feedbackHigh level feedback
Communication and documentation
![Page 10: Serenity BDD - from executable specifications to living documentation](https://reader033.vdocuments.site/reader033/viewer/2022051520/58ed9af51a28ab75278b46e5/html5/thumbnails/10.jpg)
@wakaleo
Serenity BDD
“Because life is too short to h a v e t o m a i n t a i n u g l y automated test suites”
![Page 11: Serenity BDD - from executable specifications to living documentation](https://reader033.vdocuments.site/reader033/viewer/2022051520/58ed9af51a28ab75278b46e5/html5/thumbnails/11.jpg)
@wakaleo
Living documentation
Strong Selenium WebDriver support
JUnit, Cucumber or JBehave
A layered approach
Serenity BDD
![Page 12: Serenity BDD - from executable specifications to living documentation](https://reader033.vdocuments.site/reader033/viewer/2022051520/58ed9af51a28ab75278b46e5/html5/thumbnails/12.jpg)
@wakaleo
The Serenity layered architecture
Goals
Tasks
Interactions
Tests or scenarios
“Steps”
Page Objects or other technical components
![Page 13: Serenity BDD - from executable specifications to living documentation](https://reader033.vdocuments.site/reader033/viewer/2022051520/58ed9af51a28ab75278b46e5/html5/thumbnails/13.jpg)
@wakaleo
The Serenity layered architectureFeature: Add new todos James needs to be able to jot down actions he needs to do as he thinks of them Scenario: Record a new todo action for future use Given James needs to buy some milk When James adds the todo action 'Buy some milk' Then 'Buy some milk' should be recorded in his todo list
![Page 14: Serenity BDD - from executable specifications to living documentation](https://reader033.vdocuments.site/reader033/viewer/2022051520/58ed9af51a28ab75278b46e5/html5/thumbnails/14.jpg)
@wakaleo
The Serenity layered architectureFeature: Add new todos James needs to be able to jot down actions he needs to do as he thinks of them Scenario: Record a new todo action for future use Given James needs to buy some milk When James adds the todo action 'Buy some milk' Then 'Buy some milk' should be recorded in his todo list
A goal
![Page 15: Serenity BDD - from executable specifications to living documentation](https://reader033.vdocuments.site/reader033/viewer/2022051520/58ed9af51a28ab75278b46e5/html5/thumbnails/15.jpg)
@wakaleo
The Serenity layered architectureFeature: Add new todos James needs to be able to jot down actions he needs to do as he thinks of them Scenario: Record a new todo action for future use Given James needs to buy some milk When James adds the todo action 'Buy some milk' Then 'Buy some milk' should be recorded in his todo list
A goal
A task
![Page 16: Serenity BDD - from executable specifications to living documentation](https://reader033.vdocuments.site/reader033/viewer/2022051520/58ed9af51a28ab75278b46e5/html5/thumbnails/16.jpg)
@wakaleo
The Serenity layered architectureFeature: Add new todos James needs to be able to jot down actions he needs to do as he thinks of them Scenario: Record a new todo action for future use Given James needs to buy some milk When James adds the todo action 'Buy some milk' Then 'Buy some milk' should be recorded in his todo list
A goal
A task
@Steps ATodoUser james; @When(“^(?:.*) (?:adds|has added) the todo action '(.*)'$") public void i_add_the_todo_action(String actionName) { james.adds_an_action_called(actionName);}
![Page 17: Serenity BDD - from executable specifications to living documentation](https://reader033.vdocuments.site/reader033/viewer/2022051520/58ed9af51a28ab75278b46e5/html5/thumbnails/17.jpg)
@wakaleo
The Serenity layered architectureFeature: Add new todos James needs to be able to jot down actions he needs to do as he thinks of them Scenario: Record a new todo action for future use Given James needs to buy some milk When James adds the todo action 'Buy some milk' Then 'Buy some milk' should be recorded in his todo list
A goal
A task
@Steps ATodoUser james; @When(“^(?:.*) (?:adds|has added) the todo action '(.*)'$") public void i_add_the_todo_action(String actionName) { james.adds_an_action_called(actionName);} The task definition
![Page 18: Serenity BDD - from executable specifications to living documentation](https://reader033.vdocuments.site/reader033/viewer/2022051520/58ed9af51a28ab75278b46e5/html5/thumbnails/18.jpg)
@wakaleo
The Serenity layered architectureFeature: Add new todos James needs to be able to jot down actions he needs to do as he thinks of them Scenario: Record a new todo action for future use Given James needs to buy some milk When James adds the todo action 'Buy some milk' Then 'Buy some milk' should be recorded in his todo list
A goal
A task
@Steps ATodoUser james; @When(“^(?:.*) (?:adds|has added) the todo action '(.*)'$") public void i_add_the_todo_action(String actionName) { james.adds_an_action_called(actionName);} The task definition
TodoPage onTheTodoHomePage; @Steppublic void adds_an_action_called(String actionName) { onTheTodoHomePage.addAnActionCalled(actionName);}
![Page 19: Serenity BDD - from executable specifications to living documentation](https://reader033.vdocuments.site/reader033/viewer/2022051520/58ed9af51a28ab75278b46e5/html5/thumbnails/19.jpg)
@wakaleo
The Serenity layered architectureFeature: Add new todos James needs to be able to jot down actions he needs to do as he thinks of them Scenario: Record a new todo action for future use Given James needs to buy some milk When James adds the todo action 'Buy some milk' Then 'Buy some milk' should be recorded in his todo list
A goal
A task
@Steps ATodoUser james; @When(“^(?:.*) (?:adds|has added) the todo action '(.*)'$") public void i_add_the_todo_action(String actionName) { james.adds_an_action_called(actionName);} The task definition
TodoPage onTheTodoHomePage; @Steppublic void adds_an_action_called(String actionName) { onTheTodoHomePage.addAnActionCalled(actionName);}
An interaction
![Page 20: Serenity BDD - from executable specifications to living documentation](https://reader033.vdocuments.site/reader033/viewer/2022051520/58ed9af51a28ab75278b46e5/html5/thumbnails/20.jpg)
@wakaleo
Serenity for Living DocumentationFeature: Add new todos I need to be able to jot down actions I need to do as fast as I think of them Scenario: Record a new todo action for future use Given I need to buy some milk When I add the todo action 'Buy some milk' Then 'Buy some milk' should be recorded in my todo list
![Page 21: Serenity BDD - from executable specifications to living documentation](https://reader033.vdocuments.site/reader033/viewer/2022051520/58ed9af51a28ab75278b46e5/html5/thumbnails/21.jpg)
@wakaleo
Serenity for Living DocumentationFeature: Add new todos I need to be able to jot down actions I need to do as fast as I think of them Scenario: Record a new todo action for future use Given I need to buy some milk When I add the todo action 'Buy some milk' Then 'Buy some milk' should be recorded in my todo list
![Page 22: Serenity BDD - from executable specifications to living documentation](https://reader033.vdocuments.site/reader033/viewer/2022051520/58ed9af51a28ab75278b46e5/html5/thumbnails/22.jpg)
@wakaleo
Coding demo
![Page 23: Serenity BDD - from executable specifications to living documentation](https://reader033.vdocuments.site/reader033/viewer/2022051520/58ed9af51a28ab75278b46e5/html5/thumbnails/23.jpg)
@wakaleo
Hard to apply to Single Page Apps
Need modifications to extend
Multiple Responsibilities
Bloat
Page Objects considered harmful
![Page 24: Serenity BDD - from executable specifications to living documentation](https://reader033.vdocuments.site/reader033/viewer/2022051520/58ed9af51a28ab75278b46e5/html5/thumbnails/24.jpg)
@wakaleo
Introducing the Journey Pattern
![Page 25: Serenity BDD - from executable specifications to living documentation](https://reader033.vdocuments.site/reader033/viewer/2022051520/58ed9af51a28ab75278b46e5/html5/thumbnails/25.jpg)
@wakaleo
Highly readable style
Encourages reuse and maintainable code
Small, reusable interaction components
User-centric
The Journey Pattern
![Page 26: Serenity BDD - from executable specifications to living documentation](https://reader033.vdocuments.site/reader033/viewer/2022051520/58ed9af51a28ab75278b46e5/html5/thumbnails/26.jpg)
@wakaleo
The Journey Pattern - A User-Centric model
Actors have goals I’d like to be able to recall all the things I need to do
Meet James
![Page 27: Serenity BDD - from executable specifications to living documentation](https://reader033.vdocuments.site/reader033/viewer/2022051520/58ed9af51a28ab75278b46e5/html5/thumbnails/27.jpg)
@wakaleo
The Journey Pattern - A User-Centric model
Actors have abilities I can browse the web with my browser
I can also query REST services
![Page 28: Serenity BDD - from executable specifications to living documentation](https://reader033.vdocuments.site/reader033/viewer/2022051520/58ed9af51a28ab75278b46e5/html5/thumbnails/28.jpg)
@wakaleo
I’d like to be able to recall all the things I need to do
The Journey Pattern - A User-Centric model
Actors perform tasks
I’ll add ‘Buy some milk’ to my todo list
![Page 29: Serenity BDD - from executable specifications to living documentation](https://reader033.vdocuments.site/reader033/viewer/2022051520/58ed9af51a28ab75278b46e5/html5/thumbnails/29.jpg)
@wakaleo
I’d like to be able to recall all the things I need to do
The Journey Pattern - A User-Centric model
Actors may interact with the system to perform these tasks
I’ll add ‘Buy some milk’ to my todo list
Type ‘Buy the milk’Press ‘ENTER’
![Page 30: Serenity BDD - from executable specifications to living documentation](https://reader033.vdocuments.site/reader033/viewer/2022051520/58ed9af51a28ab75278b46e5/html5/thumbnails/30.jpg)
@wakaleo
The Journey Pattern in Serenity
Actors have goals I’d like to be able to recall all the things I need to do
![Page 31: Serenity BDD - from executable specifications to living documentation](https://reader033.vdocuments.site/reader033/viewer/2022051520/58ed9af51a28ab75278b46e5/html5/thumbnails/31.jpg)
@wakaleo
The Journey Pattern in Serenity
Actors have goals
Feature: Add new todos James would like to be able to recall all the things he needs to do Scenario: Record a new todo action for future use Given James needs to buy some milk When James adds the todo action 'Buy some milk' Then 'Buy some milk' should be recorded in his todo list
I’d like to be able to recall all the things I need to do
![Page 32: Serenity BDD - from executable specifications to living documentation](https://reader033.vdocuments.site/reader033/viewer/2022051520/58ed9af51a28ab75278b46e5/html5/thumbnails/32.jpg)
@wakaleo
A User-Centric model
Actors have abilities I can browse the web with my browser
Actor james = Actor.named(“James");
@ManagedWebDriver hisBrowser; … james.can(BrowseTheWeb.with(hisBrowser));
![Page 33: Serenity BDD - from executable specifications to living documentation](https://reader033.vdocuments.site/reader033/viewer/2022051520/58ed9af51a28ab75278b46e5/html5/thumbnails/33.jpg)
@wakaleo
A User-Centric model
Actors perform tasks I’ll add ‘Buy some milk’ to my todo list
@StepsAddItem addATodoItem; … james.attemptsTo(addATodoItem.called("Buy some milk"));
![Page 34: Serenity BDD - from executable specifications to living documentation](https://reader033.vdocuments.site/reader033/viewer/2022051520/58ed9af51a28ab75278b46e5/html5/thumbnails/34.jpg)
@wakaleo
A User-Centric model
Actors perform tasks I’ll add ‘Buy some milk’ to my todo list
@StepsAddItem addATodoItem; … james.attemptsTo(addATodoItem.called("Buy some milk"));
actor.attemptsTo( Enter.theValue(thingToDo).into(ToDoList.NEW_TODO_FIELD), Hit.the(RETURN).keyIn(ToDoList.NEW_TODO_FIELD) );
![Page 35: Serenity BDD - from executable specifications to living documentation](https://reader033.vdocuments.site/reader033/viewer/2022051520/58ed9af51a28ab75278b46e5/html5/thumbnails/35.jpg)
@wakaleo
Coding demo
![Page 36: Serenity BDD - from executable specifications to living documentation](https://reader033.vdocuments.site/reader033/viewer/2022051520/58ed9af51a28ab75278b46e5/html5/thumbnails/36.jpg)
@wakaleo
References• http://www.serenity-bdd.info• https://github.com/serenity-bdd/serenity-journey-demo• http://bit.ly/rg-journey
![Page 37: Serenity BDD - from executable specifications to living documentation](https://reader033.vdocuments.site/reader033/viewer/2022051520/58ed9af51a28ab75278b46e5/html5/thumbnails/37.jpg)
Alex Soto Bueno
[email protected]@alexsotob
[email protected] wakaleo
http://www.wakaleo.com http://www.serenity-bdd.info
![Page 38: Serenity BDD - from executable specifications to living documentation](https://reader033.vdocuments.site/reader033/viewer/2022051520/58ed9af51a28ab75278b46e5/html5/thumbnails/38.jpg)
@wakaleo
Questions?John Ferguson Smart
http://www.wakaleo.comhttp://www.serenity-bdd.info