serenity and the journey pattern

86
@wakaleo The evolution of automated testing practices Take me on a journey @wakaleo

Upload: wakaleo-consulting

Post on 09-Jan-2017

3.136 views

Category:

Technology


1 download

TRANSCRIPT

Page 1: Serenity and the Journey Pattern

@wakaleo

The evolution of automated testing practicesTake me on a journey

@wakaleo

Page 2: Serenity and the Journey Pattern

@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 and the Journey Pattern

@wakaleo

Test AutomationDo it well, or don’t do it at all

Page 4: Serenity and the Journey Pattern

@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

Page 5: Serenity and the Journey Pattern

@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

Page 6: Serenity and the Journey Pattern

@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

Page 7: Serenity and the Journey Pattern

@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

Page 8: Serenity and the Journey Pattern

@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 9: Serenity and the Journey Pattern

@wakaleo

Now factor in high maintenance

40-60%Typical maintenance overhead for poorly-written test suites

Page 10: Serenity and the Journey Pattern

@wakaleo

Now factor in high maintenance

Number of tests

Main

tena

nce

over

head

Page 11: Serenity and the Journey Pattern

@wakaleo

Now factor in high maintenance

Number of tests

Main

tena

nce

over

head

Page 12: Serenity and the Journey Pattern

@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

Page 13: Serenity and the Journey Pattern

@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 14: Serenity and the Journey Pattern

@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: Serenity and the Journey Pattern

@wakaleo

Narrative Coding Style

Open-Closed Principle

Single Responsibility Principle

Separation of Concerns

Software Engineering Principles can help you write more maintainable tests

Page 16: Serenity and the Journey Pattern

@wakaleo

Narrative Coding Style

Open-Closed Principle

Single Responsibility Principle

Separation of Concerns

Software Engineering Principles can help you write more maintainable tests

Page 17: Serenity and the Journey Pattern

@wakaleo

Narrative Coding Style

Open-Closed Principle

Single Responsibility Principle

Separation of Concerns

Software Engineering Principles can help you write more maintainable tests

Page 18: Serenity and the Journey Pattern

@wakaleo

Narrative Coding Style

Open-Closed Principle

Single Responsibility Principle

Separation of Concerns

Software Engineering Principles can help you write more maintainable tests

Page 19: Serenity and the Journey Pattern

@wakaleo

Separation of Concerns - Layers

Goals

Tasks

Actions

Page 20: Serenity and the Journey Pattern

@wakaleo

Separation of Concerns - Layers

Goals

Tasks

Actions

What are you trying to achieve?

Page 21: Serenity and the Journey Pattern

@wakaleo

Separation of Concerns - Layers

Goals

Tasks

Actions

What are you trying to achieve?

What do you need to do to achieve this goal?

Page 22: Serenity and the Journey Pattern

@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 23: Serenity and the Journey Pattern

@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 24: Serenity and the Journey Pattern

@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 25: Serenity and the Journey Pattern

@wakaleo

Feature documentationDetailed feedbackHigh level feedback

Communication and documentation

Page 26: Serenity and the Journey Pattern

@wakaleo

Feature documentationDetailed feedbackHigh level feedback

Communication and documentation

Page 27: Serenity and the Journey Pattern

@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 28: Serenity and the Journey Pattern

@wakaleo

Living documentation

Strong Selenium WebDriver support

JUnit, Cucumber or JBehave

A layered approach

Serenity BDD

Page 29: Serenity and the Journey Pattern

@wakaleo

The Serenity layered architecture

Goals

Tasks

Interactions

Page 30: Serenity and the Journey Pattern

@wakaleo

The Serenity layered architecture

Goals

Tasks

Interactions

Tests or scenarios

Page 31: Serenity and the Journey Pattern

@wakaleo

The Serenity layered architecture

Goals

Tasks

Interactions

Tests or scenarios

“Steps”

Page 32: Serenity and the Journey Pattern

@wakaleo

The Serenity layered architecture

Goals

Tasks

Interactions

Tests or scenarios

“Steps”

Page Objects or other technical components

Page 33: Serenity and the Journey Pattern

@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 34: Serenity and the Journey Pattern

@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 35: Serenity and the Journey Pattern

@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 36: Serenity and the Journey Pattern

@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 37: Serenity and the Journey Pattern

@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 38: Serenity and the Journey Pattern

@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 39: Serenity and the Journey Pattern

@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 40: Serenity and the Journey Pattern

@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 41: Serenity and the Journey Pattern

@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 42: Serenity and the Journey Pattern

@wakaleo

Coding demo

Page 43: Serenity and the Journey Pattern

@wakaleo

Hard to apply to Single Page Apps

Need modifications to extend

Multiple Responsibilities

Bloat

Page Objects considered harmful

Page 44: Serenity and the Journey Pattern

@wakaleo

Introducing the Journey Pattern

Page 45: Serenity and the Journey Pattern

@wakaleo

Highly readable style

Encourages reuse and maintainable code

Small, reusable interaction components

User-centric

The Journey Pattern

Page 46: Serenity and the Journey Pattern

@wakaleo

Origins of the Journey Pattern in Serenity

Antony Marcano

2007

*

* Based on actual events

Page 47: Serenity and the Journey Pattern

@wakaleo

Origins of the Journey 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 48: Serenity and the Journey Pattern

@wakaleo

Origins of the Journey Pattern in Serenity

Antony Marcano

2007 2009

Andy Palmer

Page 49: Serenity and the Journey Pattern

@wakaleo

Origins of the Journey Pattern in Serenity

Antony Marcano

2007 2009

More people should know about this pattern

Andy Palmer

Page 50: Serenity and the Journey Pattern

@wakaleo

Origins of the Journey Pattern in Serenity

Antony Marcano

2007 2009

More people should know about this pattern

JNarrate

Andy Palmer

Let’s write a reference implementation!

Page 51: Serenity and the Journey Pattern

@wakaleo

Origins of the Journey Pattern in Serenity

Antony Marcano

2007 2009

“Coronation Streetrocks

2012

Andy Palmer

Page 52: Serenity and the Journey Pattern

@wakaleo

Origins of the Journey Pattern in Serenity

Antony Marcano

2007 2009

“Coronation Streetrocks

2012

Andy Palmer

Eureka! “Soap Opera Personas”

Page 53: Serenity and the Journey Pattern

@wakaleo

Andy Palmer

Origins of the Journey Pattern in Serenity

Antony Marcano

2007 2009 2012

Jan Molak

Page 54: Serenity and the Journey Pattern

@wakaleo

Andy Palmer

Origins of the Journey Pattern in Serenity

Antony Marcano

2007 2009 2012

Jan Molak

You should call this “The Journey Pattern”

Page 55: Serenity and the Journey Pattern

@wakaleo

Andy Palmer

Origins of the Journey Pattern in Serenity

Antony Marcano

2007 2009 2012

Jan Molak

You should call this “The Journey Pattern”Damn!

Page 56: Serenity and the Journey Pattern

@wakaleo

Andy Palmer

Origins of the Journey 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 57: Serenity and the Journey Pattern

@wakaleo

Andy Palmer

Origins of the Journey Pattern in Serenity

Antony Marcano

2007 2009 2012

Jan Molak

2015

John Smart

Page 58: Serenity and the Journey Pattern

@wakaleo

Andy Palmer

Origins of the Journey Pattern in Serenity

Antony Marcano

2007 2009 2012

Jan Molak

2015

John Smart

Serenity is cool

Page 59: Serenity and the Journey Pattern

@wakaleo

Andy Palmer

Origins of the Journey Pattern in Serenity

Antony Marcano

2007 2009 2012

Jan Molak

2015

John Smart

Serenity is cool

But it needs the Journey Pattern

Page 60: Serenity and the Journey Pattern

@wakaleo

Andy Palmer

Origins of the Journey 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 61: Serenity and the Journey Pattern

@wakaleo

The Journey Pattern - A User-Centric model

Actors have goals

Page 62: Serenity and the Journey Pattern

@wakaleo

The Journey Pattern - A User-Centric model

Actors have goals

Meet James

Page 63: Serenity and the Journey Pattern

@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 64: Serenity and the Journey Pattern

@wakaleo

The Journey Pattern - A User-Centric model

Actors have abilities

Page 65: Serenity and the Journey Pattern

@wakaleo

The Journey Pattern - A User-Centric model

Actors have abilities I can browse the web with my browser

Page 66: Serenity and the Journey Pattern

@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 67: Serenity and the Journey Pattern

@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

Page 68: Serenity and the Journey Pattern

@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 69: Serenity and the Journey Pattern

@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

Page 70: Serenity and the Journey Pattern

@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

Page 71: Serenity and the Journey Pattern

@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’

Page 72: Serenity and the Journey Pattern

@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’

Page 73: Serenity and the Journey Pattern

@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 74: Serenity and the Journey Pattern

@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 75: Serenity and the Journey Pattern

@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 76: Serenity and the Journey Pattern

@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 77: Serenity and the Journey Pattern

@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 78: Serenity and the Journey Pattern

@wakaleo

A User-Centric model

Actors perform tasks

@StepsAddItem addATodoItem; … james.attemptsTo(addATodoItem.called("Buy some milk"));

Page 79: Serenity and the Journey Pattern

@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 80: Serenity and the Journey Pattern

@wakaleo

A User-Centric model

Actors perform tasks

@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 81: Serenity and the Journey Pattern

@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 82: Serenity and the Journey Pattern

@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’

Page 83: Serenity and the Journey Pattern

@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 84: Serenity and the Journey Pattern

@wakaleo

Coding demo

Page 85: Serenity and the Journey Pattern

@wakaleo

References• http://www.serenity-bdd.info• https://github.com/serenity-bdd/serenity-journey-demo• http://bit.ly/rg-journey

Page 86: Serenity and the Journey Pattern

@wakaleo

Questions?John Ferguson Smart

[email protected]

http://www.wakaleo.comhttp://www.serenity-bdd.info