38
Demo BDD in Action John Ferguson Smart Wakaleo Consulting

BDD in Action - Automated Web Testing with WebDriver and Serenity

Embed Size (px)

DESCRIPTION

Slides from the London Agile Testing Meetup of November 25 2014: John Ferguson Smart is a specialist in BDD, automated testing and software life cycle development optimization. John is a well-known speaker at many international conferences and events and an accomplished author (John's new book BDD in Action was published last month). John presents a talk discussing how to write solid, reliable and maintainable automated web tests using the best-of-breed open source technologies like Selenium WebDriver, Serenity, JBehave and Cucumber.

Citation preview

Page 1: BDD in Action - Automated Web Testing with WebDriver and Serenity

DemoBDD in Action

John Ferguson Smart Wakaleo Consulting

Page 2: BDD in Action - Automated Web Testing with WebDriver and Serenity

Miyamoto  Musashi  Japan  

1584  –  1645

Page 3: BDD in Action - Automated Web Testing with WebDriver and Serenity

John Ferguson Smart

Consultant  Trainer  Mentor  Author  Speaker  Coder

Page 4: BDD in Action - Automated Web Testing with WebDriver and Serenity

 What  is  BDD    A  typical  BDD  workflow    What  tools  should  I  use?    Effec@ve  BDD  automa@on    BDD  Gotchas

Page 5: BDD in Action - Automated Web Testing with WebDriver and Serenity

Using examples

a shared understanding

software that matters

So what is this BDD thing?

Page 6: BDD in Action - Automated Web Testing with WebDriver and Serenity

BDD

Hunting out value Automated Acceptance Criteria

API and code design

Collaboration

Building the software right

Building the right software

Living Documentation

Page 7: BDD in Action - Automated Web Testing with WebDriver and Serenity

The business owner tells the business

analyst what he wants

12 The business

analyst writes a requirements

document

3 The developer translates the requirements into software

4 The tester translates the requirements

into test cases 5 The technical writer translates

the software into functional and technical

documentation

BDD in a nutshell

A traditional development process

Page 8: BDD in Action - Automated Web Testing with WebDriver and Serenity

The business owner and the business

analyst have a conversation about

what he needs.

1

2

3

4 The tester uses these scenarios as the basis for

her tests

5

The automated tests provide feedback on progress and help

document the application

The business analyst, the developer and the tester elaborate the

requirements together.

The scenarios guide the developer and act as

automated tests

They define requirements as

structured, English-language format

"scenarios"

•Specifica@ons  are  elaborated  collabora@vely  •Specifica@ons  use  a  common  language  •Executable  specifica@ons  provide  fast  feedback

Page 9: BDD in Action - Automated Web Testing with WebDriver and Serenity

Benefits of BDD

BDD  in  the  real  world  -­‐  an  example

BDD

Page 10: BDD in Action - Automated Web Testing with WebDriver and Serenity

BDD Gotchas

12

3

4An@-­‐paKern  1  The  business  analyst  writes  the  scenarios  and  then  gives  them  to  the  other  team  members.

Page 11: BDD in Action - Automated Web Testing with WebDriver and Serenity

12

3

4

BDD Gotchas

An@-­‐paKern  2  The  tester  writes  the  scenarios  at  the  end  to  implement  an  automated  test  suite.

Page 12: BDD in Action - Automated Web Testing with WebDriver and Serenity

1

2

3

45

BDD Gotchas

An@-­‐paKern  3  The  “Three  Amigos”  sessions  don’t  result  in  usable  scenarios,  so  the  developer  invents  them  a=erwards.

Page 13: BDD in Action - Automated Web Testing with WebDriver and Serenity

1

2

3

45

BDD Gotchas

An@-­‐paKern  4  The  scenarios  are  too  UI-­‐centric  or  detail-­‐focused,  and  neglect  to  express  the  core  business  value.

Page 14: BDD in Action - Automated Web Testing with WebDriver and Serenity

BDD for high-level requirements

Page 15: BDD in Action - Automated Web Testing with WebDriver and Serenity
Page 16: BDD in Action - Automated Web Testing with WebDriver and Serenity
Page 17: BDD in Action - Automated Web Testing with WebDriver and Serenity

Frequent Flyer Application Goal: Encourage travellers to fly with Flying High airlines more often by allowing them to cumulate Frequent Flyer points that they can spend on cheaper flights.

Goals

Earning points from flights

Capabili9es

Earning points from spending with partners

Viewing points earned

Spending points on bookings

FeaturesViewing current points balance

View points needed to achieve the next status level

Calculating points needed for a given destination

Page 18: BDD in Action - Automated Web Testing with WebDriver and Serenity

Calculating points needed for a given destination As a traveller I want to know how many points I need to go to a given destination So that I can plan my next trip with Flying High Airlines

Feature

Acceptance Criteria -Need 2 points per km -Members can calculate points needed on their account home page

Acceptance  Criteria

Automated  Acceptance  Criteria

Page 19: BDD in Action - Automated Web Testing with WebDriver and Serenity

Automated  Acceptance  Criteria

Automated  Acceptance  

Tests

Page 20: BDD in Action - Automated Web Testing with WebDriver and Serenity

Automated  Acceptance  

Tests

Applica9on  Code

Low  level  specifica9ons

Page 21: BDD in Action - Automated Web Testing with WebDriver and Serenity

A typical BDD workflow“But  what  are  the  deliverables?

Meaningful  feedback  on  what  requirements  have  (and  have  not)  been  delivered  

Page 22: BDD in Action - Automated Web Testing with WebDriver and Serenity

An incremental approach“But  what  are  the  deliverables?

Descrip9on  of  each  feature  with  an  example  of  how  it  behaves

Page 23: BDD in Action - Automated Web Testing with WebDriver and Serenity

An incremental approach“But  what  are  the  deliverables?

…complete  with  illustra9ons

Page 24: BDD in Action - Automated Web Testing with WebDriver and Serenity

An incremental approach“But  what  are  the  deliverables?

How  was  each  feature  tested?

Page 25: BDD in Action - Automated Web Testing with WebDriver and Serenity

An incremental approach“But  what  are  the  deliverables?

Documenta9on  about  what  you  plan  to  deliver  in  each  release

Page 26: BDD in Action - Automated Web Testing with WebDriver and Serenity

An incremental approach“But  what  are  the  deliverables?

Useful  low-­‐level  technical  documenta9on  with  liRle  overhead

Page 27: BDD in Action - Automated Web Testing with WebDriver and Serenity

An incremental approach

“But  what  are  the  deliverables?

…and  targeted  automated  regression  tests

Page 28: BDD in Action - Automated Web Testing with WebDriver and Serenity

BDD for detailed coding

Page 29: BDD in Action - Automated Web Testing with WebDriver and Serenity

Business Goal

Business Goal

Business Goal

We  can  automate  these  examples  in  the  form  of  “executable  specifica@ons”

FeaturesFeaturesFeatures FeaturesFeaturesExamplesLow level

specificationsLow level specificationsLow level specifications

Executable specifications

“building the software right”

Page 30: BDD in Action - Automated Web Testing with WebDriver and Serenity

Business Goal

Business Goal

Business Goal

We  use  low-­‐level  BDD  or  TDD  tools  to  define  the  behavior  of  components,  classes  etc.

FeaturesFeaturesFeatures FeaturesFeaturesExamplesLow level

specificationsLow level specificationsLow level specifications

Executable specifications

spockRSpec

“building the software right”

Low level specifications

Low level specifications

Low level specifications

Low level specifications

Low level specifications

Page 31: BDD in Action - Automated Web Testing with WebDriver and Serenity

Acceptance  criteria  tell  us  what  we  need  to  build…

“building the software right”

Page 32: BDD in Action - Automated Web Testing with WebDriver and Serenity

What  would  we  like  the  API  to  look  like?

“building the software right”

Page 33: BDD in Action - Automated Web Testing with WebDriver and Serenity

Then  write  low-­‐level  specifica@ons  for  the  code

“building the software right”

Page 34: BDD in Action - Automated Web Testing with WebDriver and Serenity

“building the software right”

These  low  level  specifica@ons  become  technical  documenta@on  for  your  APIs

Page 35: BDD in Action - Automated Web Testing with WebDriver and Serenity

What tool should I use?

Page 36: BDD in Action - Automated Web Testing with WebDriver and Serenity

Collaboration before Automation

“Having  the  conversaDon    is  more  important  than    

recording  the  conversaDon  is  more  important  than    

automaDng  the  conversaDon”  -­‐  Liz  Keogh

Page 37: BDD in Action - Automated Web Testing with WebDriver and Serenity

Know your audience

Page 38: BDD in Action - Automated Web Testing with WebDriver and Serenity

DemoThank You