49
#DevoxxPL @wakaleo #beyondgwt BEYOND GIVEN/WHEN/THEN Why diving into Cucumber is the wrong approach to adopting BDD @wakaleo www.johnfergusonsmart.com

Beyond Given/When/Then - why diving into Cucumber is the wrong approach to adopting BDD

Embed Size (px)

Citation preview

Page 1: Beyond Given/When/Then - why diving into Cucumber is the wrong approach to adopting BDD

#DevoxxPL#DevoxxPL @wakaleo #beyondgwt

BEYOND GIVEN/WHEN/THEN Why diving into Cucumber is the wrong approach to adopting BDD

@wakaleo

www.johnfergusonsmart.com

Page 2: Beyond Given/When/Then - why diving into Cucumber is the wrong approach to adopting BDD

#DevoxxPL#DevoxxPL @wakaleo #beyondgwt

“You do BDD? Cool, I love test automation!”

“We couldn’t do BDD this sprint because we didn’t have any UI stories”

“Yes, we do BDD here, the tester uses Cucumber for all his tests”

“We're dev complete so let's write some Bee-Dee-Dees”

“The Jira story is not complete until the BA defines their given-when-thens”

Page 3: Beyond Given/When/Then - why diving into Cucumber is the wrong approach to adopting BDD

#DevoxxPL#DevoxxPL @wakaleo #beyondgwt

BDD is NOT

Using “Given-When-Then” in your stories

Though you may find the Given/When/Then structure useful at certain stages when you practice BDD

Page 4: Beyond Given/When/Then - why diving into Cucumber is the wrong approach to adopting BDD

#DevoxxPL#DevoxxPL @wakaleo #beyondgwt

BDD is NOT

Using Cucumber to write automated web tests

Though you may find Cucumber useful at certain stages when you practice BDD

Page 5: Beyond Given/When/Then - why diving into Cucumber is the wrong approach to adopting BDD

#DevoxxPL#DevoxxPL @wakaleo #beyondgwt

BDD ISA way of collaborating

using conversations about examples and business rules to deliver better software

Page 6: Beyond Given/When/Then - why diving into Cucumber is the wrong approach to adopting BDD

#DevoxxPL#DevoxxPL @wakaleo #beyondgwt

To deliver software that matters

And a common language to build a shared understanding

Using rules and examples at multiple levels

Collaborate to discover requirements and identify uncertainty

Page 7: Beyond Given/When/Then - why diving into Cucumber is the wrong approach to adopting BDD

#DevoxxPL#DevoxxPL @wakaleo #beyondgwt

Business

BA

Developers

Testers

As a corporate frequent flyer I want to earn points on my business flights So that I can get discounts on my holiday flights

Examples

Rules

Acceptance Criteria

SHARED UNDERSTANDING

Executable Specifications

Scenario: First class earns double points Given I fly from London to Paris When I am in First Class Then I should earn twice as many points

Scenario: First class earns double points Given I fly from London to Paris When I am in First Class Then I should earn twice as many points

Development and exploratory testing

Software that matters

Page 8: Beyond Given/When/Then - why diving into Cucumber is the wrong approach to adopting BDD

#DevoxxPL#DevoxxPL @wakaleo #beyondgwt

Discover

Define

Formalise

Automate

Gherkin

Cucumber

Page 9: Beyond Given/When/Then - why diving into Cucumber is the wrong approach to adopting BDD

#DevoxxPL#DevoxxPL @wakaleo #beyondgwt

Gherkins get people together

Page 10: Beyond Given/When/Then - why diving into Cucumber is the wrong approach to adopting BDD

#DevoxxPL#DevoxxPL @wakaleo #beyondgwt

Scenario: Applying for a joint credit card with insufficient combined income The combined income must be over £10,000

Given Susan has an income of £3000 And Jim has an income of £2500 When Susan and Jim apply for a joint credit card online Then the application should be refused

What rule are we illustrating

Preconditions

Action

Expected outcome

Gherkin: a simple but flexible format

Page 11: Beyond Given/When/Then - why diving into Cucumber is the wrong approach to adopting BDD

#DevoxxPL#DevoxxPL @wakaleo #beyondgwt

Feature: Credit card financial checks In order to avoid bad debts As a financial institution I want to ensure that a customer’s credit limit is in line with the their earnings

Scenario Outline: The maximum credit card limit depends on the customer's salary

A customer needs a salary of at least £10,000. There are two types of card, one with a limit of £2500, and another with a limit of £5000

Given an individual customer with an annual salary of <Salary> When the customer applies for a credit card Then the credit card application should be <Approved or Refused> And if approved, the maximum credit limit should be <Max Limit> Examples:

| Salary | Approved or Refused | Max Limit | Notes | | £5000 | Refused | 0 | must be over £10,000 | | £15,000 | Approved | £2500 | Up to £15,000 | | £25,000 | Approved | £5000 | Over £15,000 | | £100,000 | Approved | £5000 | Max limit £5000 |

Gherkin: a simple but flexible formatWhy

What

How

Examples

Page 12: Beyond Given/When/Then - why diving into Cucumber is the wrong approach to adopting BDD

#DevoxxPL#DevoxxPL @wakaleo #beyondgwt

“I wrote you a long letter because I didn’t have time to write a short one”

- Mark Twain

Page 13: Beyond Given/When/Then - why diving into Cucumber is the wrong approach to adopting BDD

#DevoxxPL#DevoxxPL @wakaleo #beyondgwt

Feature: Display customer details As a user I want to view the customer's personal profile In order to access the personal information on the customer

Scenario: Customer Profile field 'Gender' Given I am logged into the application And I have displayed the customer When I view the customer profile on the summary screen Then I should see the Gender field (field type: Dropdown - read only information) Scenario: Customer Profile ‘DOB/Age' field Given I am logged into the application And I have displayed the customer When I view the Personal Profile on the Summary screen Then I should see the DOB/Age field (DOB field type: Date, format: dd mmm yyyy - read only) (Age field type:read only - numeric) under Personal Profile And it should be blank if no value returned

Scenario: Customer Profile 'Marital Status' field Scenario: Customer Profile 'Dependents' field

The Gherkin notation is not a guarantee of quality

Page 14: Beyond Given/When/Then - why diving into Cucumber is the wrong approach to adopting BDD

#DevoxxPL#DevoxxPL @wakaleo #beyondgwt

When G/W/T happens too early

“The Jira story is not complete until the BA defines their given-when-thens”

Page 15: Beyond Given/When/Then - why diving into Cucumber is the wrong approach to adopting BDD

#DevoxxPL#DevoxxPL @wakaleo #beyondgwt

Page 16: Beyond Given/When/Then - why diving into Cucumber is the wrong approach to adopting BDD

#DevoxxPL#DevoxxPL @wakaleo #beyondgwt

Scenario Outline: User tries to log on to application with invalid credentials Given I am a registered user When I login as <username> with password <password> Then I should not be allowed to logon And I should see the error message <error-message> Examples: | username | password | message | | scott | | Please enter a password | | | tiger | Please enter a username | | scott | wrong | Invalid username or password |

Sure, but what else?

Page 17: Beyond Given/When/Then - why diving into Cucumber is the wrong approach to adopting BDD

#DevoxxPL#DevoxxPL @wakaleo #beyondgwt

When G/W/T happens too late

“Yes, we do BDD here, the tester uses Cucumber for all his tests”

“We're dev complete so let's write some Bee-Dee-Dees”

“You do BDD? Cool, I love test automation!”

Page 18: Beyond Given/When/Then - why diving into Cucumber is the wrong approach to adopting BDD

#DevoxxPL#DevoxxPL @wakaleo #beyondgwt

Page 19: Beyond Given/When/Then - why diving into Cucumber is the wrong approach to adopting BDD

#DevoxxPL#DevoxxPL @wakaleo #beyondgwt

Page 20: Beyond Given/When/Then - why diving into Cucumber is the wrong approach to adopting BDD

#DevoxxPL#DevoxxPL @wakaleo #beyondgwt

A better approach?

Page 21: Beyond Given/When/Then - why diving into Cucumber is the wrong approach to adopting BDD

#DevoxxPL#DevoxxPL @wakaleo #beyondgwt

establishes validatesShared Understanding

Collaboration Formalisation

Sprint Planning Sprint Delivery

Page 22: Beyond Given/When/Then - why diving into Cucumber is the wrong approach to adopting BDD

#DevoxxPL#DevoxxPL @wakaleo #beyondgwt

Advocate

Sceptic Cross-Examiner

What should it do?

How can it work?What can go wrong? How can we prove it works?

Page 23: Beyond Given/When/Then - why diving into Cucumber is the wrong approach to adopting BDD

#DevoxxPL#DevoxxPL @wakaleo #beyondgwt

Discover

Page 24: Beyond Given/When/Then - why diving into Cucumber is the wrong approach to adopting BDD

#DevoxxPL#DevoxxPL @wakaleo #beyondgwt

Framing the question

Page 25: Beyond Given/When/Then - why diving into Cucumber is the wrong approach to adopting BDD

#DevoxxPL#DevoxxPL @wakaleo #beyondgwt

✓Impact Mapping ✓Story Mapping ✓Event Storming

The Bigger Picture

Page 26: Beyond Given/When/Then - why diving into Cucumber is the wrong approach to adopting BDD

#DevoxxPL#DevoxxPL @wakaleo #beyondgwt

Define

Page 27: Beyond Given/When/Then - why diving into Cucumber is the wrong approach to adopting BDD

#DevoxxPL#DevoxxPL @wakaleo #beyondgwt

Identify the outputs

Page 28: Beyond Given/When/Then - why diving into Cucumber is the wrong approach to adopting BDD

#DevoxxPL#DevoxxPL @wakaleo #beyondgwt

Find Key Rules and Examples

Rich guy Joe successfully

orders a card

Student Billy can’t order a card because his income is too low

Salary must be sufficient

✓Example Mapping

Page 29: Beyond Given/When/Then - why diving into Cucumber is the wrong approach to adopting BDD

#DevoxxPL#DevoxxPL @wakaleo #beyondgwt

Explore flows

Rich guy Joe successfully

orders a card

Applies for card

His credit rating is OK

His salary is sufficient

An account is created

The credit card is posted

✓Feature Mapping

Page 30: Beyond Given/When/Then - why diving into Cucumber is the wrong approach to adopting BDD

#DevoxxPL#DevoxxPL @wakaleo #beyondgwt

Explore variations

Rich guy Joe successfully

orders a card

Applies for card

His credit rating is OK

His salary is sufficient

An account is created

The credit card is posted

Student Billy can’t order a

card

Applies for card

His credit rating is OK

His salary is not sufficient

His application is rejected

Page 31: Beyond Given/When/Then - why diving into Cucumber is the wrong approach to adopting BDD

#DevoxxPL#DevoxxPL @wakaleo #beyondgwt

Formalise

Page 32: Beyond Given/When/Then - why diving into Cucumber is the wrong approach to adopting BDD

#DevoxxPL#DevoxxPL @wakaleo #beyondgwt

Write executable specifications

Feature: Credit card financial checks In order to avoid bad debts As a financial institution I want to ensure that a customer’s credit limit is in line with the their earnings

Scenario Outline: The maximum credit card limit depends on the customer's salary

A customer needs a salary of at least £10,000. There are two types of card, one with a limit of £2500, and another with a limit of £5000

Given an individual customer with an annual salary of <Salary> When the customer applies for a credit card Then the credit card application should be <Approved or Refused> And if approved, the maximum credit limit should be <Max Limit> Examples:

| Salary | Approved or Refused | Max Limit | Notes | | £5000 | Refused | 0 | must be over £10,000 | | £15,000 | Approved | £2500 | Up to £15,000 | | £25,000 | Approved | £5000 | Over £15,000 | | £100,000 | Approved | £5000 | Max limit £5000 |

Page 33: Beyond Given/When/Then - why diving into Cucumber is the wrong approach to adopting BDD

#DevoxxPL#DevoxxPL @wakaleo #beyondgwtAutomate

Page 34: Beyond Given/When/Then - why diving into Cucumber is the wrong approach to adopting BDD

#DevoxxPL#DevoxxPL @wakaleo #beyondgwt

Automate

Feature: Credit card financial checks In order to avoid bad debts As a financial institution I want to ensure that a customer’s credit limit is in line with the their earnings

Scenario Outline: The maximum credit card limit depends on the customer's salary

A customer needs a salary of at least £10,000. There are two types of card, one with a limit of £2500, and another with a limit of £5000

Given an individual customer with an annual salary of <Salary> When the customer applies for a credit card Then the credit card application should be <Approved or Refused> And if approved, the maximum credit limit should be <Max Limit> Examples:

| Salary | Approved or Refused | Max Limit | Notes | | £5000 | Refused | 0 | must be over £10,000 | | £15,000 | Approved | £2500 | Up to £15,000 | | £25,000 | Approved | £5000 | Over £15,000 | | £100,000 | Approved | £5000 | Max limit £5000 |

Page 35: Beyond Given/When/Then - why diving into Cucumber is the wrong approach to adopting BDD

#DevoxxPL#DevoxxPL @wakaleo #beyondgwt

Example Mapping

Examples and Rules

Page 36: Beyond Given/When/Then - why diving into Cucumber is the wrong approach to adopting BDD

#DevoxxPL#DevoxxPL @wakaleo #beyondgwt

Example Mapping

Story

Rules

Examples

Questions

Examples and Rules

Page 37: Beyond Given/When/Then - why diving into Cucumber is the wrong approach to adopting BDD

#DevoxxPL#DevoxxPL @wakaleo #beyondgwt

Feature Mapping

Exploring the flow

Page 38: Beyond Given/When/Then - why diving into Cucumber is the wrong approach to adopting BDD

#DevoxxPL#DevoxxPL @wakaleo #beyondgwt

Feature Mapping

Exploring the flow

Story

A rule

An Example

Steps

Page 39: Beyond Given/When/Then - why diving into Cucumber is the wrong approach to adopting BDD

#DevoxxPL#DevoxxPL @wakaleo #beyondgwt

Feature Mapping

Exploring the flow

Page 40: Beyond Given/When/Then - why diving into Cucumber is the wrong approach to adopting BDD

#DevoxxPL#DevoxxPL @wakaleo #beyondgwt

Feature Mapping

Exploring the flow

“Poi

nts

per

dest

inat

ion”

sto

ry“D

iffer

ent t

rave

l cl

asse

s” s

tory

Page 41: Beyond Given/When/Then - why diving into Cucumber is the wrong approach to adopting BDD

#DevoxxPL#DevoxxPL @wakaleo #beyondgwt

The six stages of BDD Maturity

Name Focus Benefits

Page 42: Beyond Given/When/Then - why diving into Cucumber is the wrong approach to adopting BDD

#DevoxxPL#DevoxxPL @wakaleo #beyondgwt

The six stages of BDD Maturity

Name Focus Benefits

Siloed

Page 43: Beyond Given/When/Then - why diving into Cucumber is the wrong approach to adopting BDD

#DevoxxPL#DevoxxPL @wakaleo #beyondgwt

The six stages of BDD Maturity

Name Focus Benefits

Colocated Breaking down the silos Reduce delivery bottlenecks

Siloed

Page 44: Beyond Given/When/Then - why diving into Cucumber is the wrong approach to adopting BDD

#DevoxxPL#DevoxxPL @wakaleo #beyondgwt

The six stages of BDD Maturity

Name Focus Benefits

Engaged Improving collaboration Prevent bugs and deliver the right product

Colocated Breaking down the silos Reduce delivery bottlenecks

Siloed

Page 45: Beyond Given/When/Then - why diving into Cucumber is the wrong approach to adopting BDD

#DevoxxPL#DevoxxPL @wakaleo #beyondgwt

The six stages of BDD Maturity

Name Focus Benefits

Mechanised Effective automation Deliver the right product faster

Engaged Improving collaboration Prevent bugs and deliver the right product

Colocated Breaking down the silos Reduce delivery bottlenecks

Siloed

Page 46: Beyond Given/When/Then - why diving into Cucumber is the wrong approach to adopting BDD

#DevoxxPL#DevoxxPL @wakaleo #beyondgwt

The six stages of BDD Maturity

Name Focus Benefits

Pioneering Leverage Delight the customer

Mechanised Effective automation Deliver the right product faster

Engaged Improving collaboration Prevent bugs and deliver the right product

Colocated Breaking down the silos Reduce delivery bottlenecks

Siloed

Page 47: Beyond Given/When/Then - why diving into Cucumber is the wrong approach to adopting BDD

#DevoxxPL#DevoxxPL @wakaleo #beyondgwt

The six stages of BDD Maturity

Name Focus Benefits

Projecting Experimentation Deliver value faster, and learning from it

Pioneering Leverage Delight the customer

Mechanised Effective automation Deliver the right product faster

Engaged Improving collaboration Prevent bugs and deliver the right product

Colocated Breaking down the silos Reduce delivery bottlenecks

Siloed

Page 48: Beyond Given/When/Then - why diving into Cucumber is the wrong approach to adopting BDD

#DevoxxPL#DevoxxPL @wakaleo #beyondgwt

Would you like to know more?

Subscribe to the newsletter

https://www.johnfergusonsmart.com

Read the book!

Page 49: Beyond Given/When/Then - why diving into Cucumber is the wrong approach to adopting BDD

#DevoxxPL#DevoxxPL @wakaleo #beyondgwt

QUESTIONS?

www.johnfergusonsmart.com

@wakaleo