![Page 1: All the world's a stage – the next step in automated testing practices](https://reader031.vdocument.in/reader031/viewer/2022030316/587291861a28ab36118b64af/html5/thumbnails/1.jpg)
@JanMolak@wakaleo
The next step in automated testing practicesAll the world’s a stage
![Page 2: All the world's a stage – the next step in automated testing practices](https://reader031.vdocument.in/reader031/viewer/2022030316/587291861a28ab36118b64af/html5/thumbnails/2.jpg)
@wakaleo @JanMolak
John Ferguson
Smart
John Ferguson Smart
“I help teams of smart people learn to work together more efficiently,
to deliver better software sooner”
![Page 3: All the world's a stage – the next step in automated testing practices](https://reader031.vdocument.in/reader031/viewer/2022030316/587291861a28ab36118b64af/html5/thumbnails/3.jpg)
@wakaleo @JanMolak
Jan Molak“Having great ideas is not enough,
it’s the execution that matters”
JanMolak [email protected]
Jan Molak
![Page 4: All the world's a stage – the next step in automated testing practices](https://reader031.vdocument.in/reader031/viewer/2022030316/587291861a28ab36118b64af/html5/thumbnails/4.jpg)
@wakaleo @JanMolak
Test AutomationDo it well, or don’t do it at all
![Page 5: All the world's a stage – the next step in automated testing practices](https://reader031.vdocument.in/reader031/viewer/2022030316/587291861a28ab36118b64af/html5/thumbnails/5.jpg)
@JanMolak@wakaleo
How much are your tests worth?
Weekly cost vs
weekly savings$0
$20,000
$40,000
$60,000
$80,000
$100,000
$120,000
$140,000
$160,000
$180,000
1/09/2015 1/10/2015 1/11/2015 1/12/2015
Test0suite0cost0vs0savings0(per0week)
Cost0saved0par0week Test0suite0cost0per0week
Team cost is constant
Time saved increases with the number of executed tests
![Page 6: All the world's a stage – the next step in automated testing practices](https://reader031.vdocument.in/reader031/viewer/2022030316/587291861a28ab36118b64af/html5/thumbnails/6.jpg)
@JanMolak@wakaleo
How much are your tests worth?
$0
$200,000
$400,000
$600,000
$800,000
$1,000,000
$1,200,000
1/09/2015 1/10/2015 1/11/2015 1/12/2015
What0is0your0test0suite0worth?
Test0suite0ROI Test0suite0cost
Cumulated cost vs
cumulated savings
Cumulated value should increase faster than cumulated cost
![Page 7: All the world's a stage – the next step in automated testing practices](https://reader031.vdocument.in/reader031/viewer/2022030316/587291861a28ab36118b64af/html5/thumbnails/7.jpg)
@JanMolak@wakaleo
Now factor in high maintenance
40-60%Typical maintenance overhead for poorly-written test suites
![Page 8: All the world's a stage – the next step in automated testing practices](https://reader031.vdocument.in/reader031/viewer/2022030316/587291861a28ab36118b64af/html5/thumbnails/8.jpg)
@JanMolak@wakaleo
Now factor in high maintenance
Number of tests
Main
tena
nce
over
head
![Page 9: All the world's a stage – the next step in automated testing practices](https://reader031.vdocument.in/reader031/viewer/2022030316/587291861a28ab36118b64af/html5/thumbnails/9.jpg)
@JanMolak@wakaleo
$0$50,000
$100,000$150,000$200,000$250,000$300,000$350,000$400,000$450,000$500,000
1/09/2015 1/10/2015 1/11/2015 1/12/2015 1/01/2016
What0is0your0test0suite0worth?
Test0suite0cost Test0suite0ROI
Now factor in high maintenance
High-maintenance costs reduce the number of tests a team can write
High maintenance costs can cause your test suite to lose value
![Page 10: All the world's a stage – the next step in automated testing practices](https://reader031.vdocument.in/reader031/viewer/2022030316/587291861a28ab36118b64af/html5/thumbnails/10.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 11: All the world's a stage – the next step in automated testing practices](https://reader031.vdocument.in/reader031/viewer/2022030316/587291861a28ab36118b64af/html5/thumbnails/11.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 12: All the world's a stage – the next step in automated testing practices](https://reader031.vdocument.in/reader031/viewer/2022030316/587291861a28ab36118b64af/html5/thumbnails/12.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 13: All the world's a stage – the next step in automated testing practices](https://reader031.vdocument.in/reader031/viewer/2022030316/587291861a28ab36118b64af/html5/thumbnails/13.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 14: All the world's a stage – the next step in automated testing practices](https://reader031.vdocument.in/reader031/viewer/2022030316/587291861a28ab36118b64af/html5/thumbnails/14.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 15: All the world's a stage – the next step in automated testing practices](https://reader031.vdocument.in/reader031/viewer/2022030316/587291861a28ab36118b64af/html5/thumbnails/15.jpg)
@JanMolak@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 16: All the world's a stage – the next step in automated testing practices](https://reader031.vdocument.in/reader031/viewer/2022030316/587291861a28ab36118b64af/html5/thumbnails/16.jpg)
16
![Page 17: All the world's a stage – the next step in automated testing practices](https://reader031.vdocument.in/reader031/viewer/2022030316/587291861a28ab36118b64af/html5/thumbnails/17.jpg)
@JanMolak@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 18: All the world's a stage – the next step in automated testing practices](https://reader031.vdocument.in/reader031/viewer/2022030316/587291861a28ab36118b64af/html5/thumbnails/18.jpg)
@JanMolak@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'
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 19: All the world's a stage – the next step in automated testing practices](https://reader031.vdocument.in/reader031/viewer/2022030316/587291861a28ab36118b64af/html5/thumbnails/19.jpg)
@wakaleo
Feature documentationDetailed feedbackHigh level feedback
Communication and documentation
![Page 20: All the world's a stage – the next step in automated testing practices](https://reader031.vdocument.in/reader031/viewer/2022030316/587291861a28ab36118b64af/html5/thumbnails/20.jpg)
@wakaleo @JanMolak
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 21: All the world's a stage – the next step in automated testing practices](https://reader031.vdocument.in/reader031/viewer/2022030316/587291861a28ab36118b64af/html5/thumbnails/21.jpg)
@wakaleo
Living documentation
Strong Selenium WebDriver support
JUnit, Cucumber or JBehave
A layered approach
Serenity BDD
![Page 22: All the world's a stage – the next step in automated testing practices](https://reader031.vdocument.in/reader031/viewer/2022030316/587291861a28ab36118b64af/html5/thumbnails/22.jpg)
@JanMolak@wakaleo
The Serenity layered architecture
Goals
Tasks
Interactions
Tests or scenarios
“Steps”
Page Objects or other technical components
![Page 23: All the world's a stage – the next step in automated testing practices](https://reader031.vdocument.in/reader031/viewer/2022030316/587291861a28ab36118b64af/html5/thumbnails/23.jpg)
@JanMolak@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 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 24: All the world's a stage – the next step in automated testing practices](https://reader031.vdocument.in/reader031/viewer/2022030316/587291861a28ab36118b64af/html5/thumbnails/24.jpg)
@JanMolak@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 25: All the world's a stage – the next step in automated testing practices](https://reader031.vdocument.in/reader031/viewer/2022030316/587291861a28ab36118b64af/html5/thumbnails/25.jpg)
@wakaleo
Coding demo
![Page 26: All the world's a stage – the next step in automated testing practices](https://reader031.vdocument.in/reader031/viewer/2022030316/587291861a28ab36118b64af/html5/thumbnails/26.jpg)
26
![Page 27: All the world's a stage – the next step in automated testing practices](https://reader031.vdocument.in/reader031/viewer/2022030316/587291861a28ab36118b64af/html5/thumbnails/27.jpg)
@wakaleo
Hard to apply to Single Page Apps
Need modifications to extend
Multiple Responsibilities
Bloat
Page Objects considered harmful
![Page 28: All the world's a stage – the next step in automated testing practices](https://reader031.vdocument.in/reader031/viewer/2022030316/587291861a28ab36118b64af/html5/thumbnails/28.jpg)
@wakaleo @JanMolak
Introducing the Screenplay Pattern
![Page 29: All the world's a stage – the next step in automated testing practices](https://reader031.vdocument.in/reader031/viewer/2022030316/587291861a28ab36118b64af/html5/thumbnails/29.jpg)
@wakaleo
Highly readable style
Encourages reuse and maintainable, scaleable code
Small, reusable interaction components
User-centric
The Screenplay Pattern
![Page 30: All the world's a stage – the next step in automated testing practices](https://reader031.vdocument.in/reader031/viewer/2022030316/587291861a28ab36118b64af/html5/thumbnails/30.jpg)
@JanMolak@wakaleo
Origins of the Screenplay Pattern in Serenity
Antony Marcano
“Page Objects kinda suck. Why not try this pattern instead?”
Agile Alliance Functional Test Tools Workshop 2007
2007
*
* Based on actual events
![Page 31: All the world's a stage – the next step in automated testing practices](https://reader031.vdocument.in/reader031/viewer/2022030316/587291861a28ab36118b64af/html5/thumbnails/31.jpg)
@JanMolak@wakaleo
Origins of the Screenplay Pattern in Serenity
Antony Marcano
2007 2009
More people should know about this pattern
JNarrate
Andy Palmer
Let’s write a reference implementation!
![Page 32: All the world's a stage – the next step in automated testing practices](https://reader031.vdocument.in/reader031/viewer/2022030316/587291861a28ab36118b64af/html5/thumbnails/32.jpg)
@JanMolak@wakaleo
Origins of the Screenplay Pattern in Serenity
Antony Marcano
2007 2009
“Coronation Street” rocks
2012
Andy Palmer
Eureka! “Soap Opera Personas”
![Page 33: All the world's a stage – the next step in automated testing practices](https://reader031.vdocument.in/reader031/viewer/2022030316/587291861a28ab36118b64af/html5/thumbnails/33.jpg)
@JanMolak@wakaleo
Andy Palmer
Origins of the Screenplay Pattern in Serenity
Antony Marcano
2007 2009 2012
Jan Molak
You should call this “The Journey Pattern”Damn!
Why didn’t we think of that!
![Page 34: All the world's a stage – the next step in automated testing practices](https://reader031.vdocument.in/reader031/viewer/2022030316/587291861a28ab36118b64af/html5/thumbnails/34.jpg)
@JanMolak@wakaleo
Andy Palmer
Origins of the Screenplay Pattern in Serenity
Antony Marcano
2007 2009 2012
Jan Molak
2015
John Smart
Serenity is cool
So let’s make it happen!
But it needs the Journey Pattern
![Page 35: All the world's a stage – the next step in automated testing practices](https://reader031.vdocument.in/reader031/viewer/2022030316/587291861a28ab36118b64af/html5/thumbnails/35.jpg)
@JanMolak@wakaleo
Andy Palmer
Origins of the Screenplay Pattern in Serenity
Antony Marcano
2007 2009 2012 2015
John Smart
Actually, the pattern has evolved a lot
Jan MolakLet’s call it the ‘Screenplay’ pattern
![Page 36: All the world's a stage – the next step in automated testing practices](https://reader031.vdocument.in/reader031/viewer/2022030316/587291861a28ab36118b64af/html5/thumbnails/36.jpg)
@JanMolak@wakaleo
The Screenplay 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 37: All the world's a stage – the next step in automated testing practices](https://reader031.vdocument.in/reader031/viewer/2022030316/587291861a28ab36118b64af/html5/thumbnails/37.jpg)
@JanMolak@wakaleo
The Screenplay Pattern - A User-Centric model
Actors have abilities I can browse the web with my browser
I can also query REST services
![Page 38: All the world's a stage – the next step in automated testing practices](https://reader031.vdocument.in/reader031/viewer/2022030316/587291861a28ab36118b64af/html5/thumbnails/38.jpg)
@JanMolak@wakaleo
I’d like to be able to recall all the things I need to do
The Screenplay Pattern - A User-Centric model
Actors perform tasks
I’ll add ‘Buy some milk’ to my todo list
![Page 39: All the world's a stage – the next step in automated testing practices](https://reader031.vdocument.in/reader031/viewer/2022030316/587291861a28ab36118b64af/html5/thumbnails/39.jpg)
@JanMolak@wakaleo
I’d like to be able to recall all the things I need to do
The Screenplay 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 40: All the world's a stage – the next step in automated testing practices](https://reader031.vdocument.in/reader031/viewer/2022030316/587291861a28ab36118b64af/html5/thumbnails/40.jpg)
@JanMolak@wakaleo
The Screenplay 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 41: All the world's a stage – the next step in automated testing practices](https://reader031.vdocument.in/reader031/viewer/2022030316/587291861a28ab36118b64af/html5/thumbnails/41.jpg)
@JanMolak@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 42: All the world's a stage – the next step in automated testing practices](https://reader031.vdocument.in/reader031/viewer/2022030316/587291861a28ab36118b64af/html5/thumbnails/42.jpg)
@JanMolak@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 43: All the world's a stage – the next step in automated testing practices](https://reader031.vdocument.in/reader031/viewer/2022030316/587291861a28ab36118b64af/html5/thumbnails/43.jpg)
@JanMolak@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) );
Type ‘Buy the milk’
Press ‘ENTER’
![Page 44: All the world's a stage – the next step in automated testing practices](https://reader031.vdocument.in/reader031/viewer/2022030316/587291861a28ab36118b64af/html5/thumbnails/44.jpg)
@JanMolak@wakaleo
A User-Centric model
james.should(seeThat(TheItems.displayed(), hasItem("Buy some milk")));
using a Hamcrest matcher
of a question regarding the state of the application
Check the answer
![Page 45: All the world's a stage – the next step in automated testing practices](https://reader031.vdocument.in/reader031/viewer/2022030316/587291861a28ab36118b64af/html5/thumbnails/45.jpg)
@JanMolak@wakaleo
A User-Centric model
Actor
Abilities
has
Tasks
Actions
performs
made up of
enable
Questions
asks
Elements
interact with
about the state of
Screenon a
![Page 46: All the world's a stage – the next step in automated testing practices](https://reader031.vdocument.in/reader031/viewer/2022030316/587291861a28ab36118b64af/html5/thumbnails/46.jpg)
@wakaleo
Coding demo
![Page 47: All the world's a stage – the next step in automated testing practices](https://reader031.vdocument.in/reader031/viewer/2022030316/587291861a28ab36118b64af/html5/thumbnails/47.jpg)
47
![Page 48: All the world's a stage – the next step in automated testing practices](https://reader031.vdocument.in/reader031/viewer/2022030316/587291861a28ab36118b64af/html5/thumbnails/48.jpg)
@wakaleo
Focus on the user journey and a common business vocabulary
Scales well to teams with varying levels of experience
Good design principles leading to lower maintenance costs
Code reuse within and across teams
Key Benefits
![Page 49: All the world's a stage – the next step in automated testing practices](https://reader031.vdocument.in/reader031/viewer/2022030316/587291861a28ab36118b64af/html5/thumbnails/49.jpg)
@JanMolak@wakaleo
References• https://github.com/serenity-bdd/serenity-web-todomvc-journey• “Beyond Page Objects: Next Generation Test Automation with
Serenity and the Screenplay Pattern” - InfoQ• “Page Objects Refactored: SOLID Steps to the Screenplay/
Journey Pattern” - DZone• http://www.serenity-bdd.info
![Page 50: All the world's a stage – the next step in automated testing practices](https://reader031.vdocument.in/reader031/viewer/2022030316/587291861a28ab36118b64af/html5/thumbnails/50.jpg)
@JanMolak@wakaleo
Want to learn more? Ask us about training and mentoring
John Ferguson Smart
wakaleohttp://johnfergusonsmart.com
Jan Molakhttp://janmolak.com
JanMolak