Top Banner
bit.ly/bdd-antipatterns-draw @wakaleo 1 BDD Anti-patterns Stories from the trenches about how not to do BDD
87

BDD Anti-patterns

Jan 09, 2017

Download

Software

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: BDD Anti-patterns

bit.ly/bdd-antipatterns-draw @wakaleo

1

BDD Anti-patterns

Stories from the trenches about how not to do BDD

Page 2: BDD Anti-patterns

John Ferguson Smart“I help teams of smart people

learn to work together more efficiently, to deliver better software faster”

wakaleo [email protected]

Page 3: BDD Anti-patterns

bit.ly/bdd-antipatterns-draw @wakaleo

To deliver software that matters

And a common language to build a shared understanding

Using examples at multiple levels

Collaborate to discover requirements and identify uncertainty

The essence of BDD

Page 4: BDD Anti-patterns

bit.ly/bdd-antipatterns-draw @wakaleo

To deliver software that matters

And a common language to build a shared understanding

Using examples at multiple levels

Collaborate to discover requirements and identify uncertainty

The essence of BDD

Page 5: BDD Anti-patterns

bit.ly/bdd-antipatterns-draw @wakaleo

To deliver software that matters

And a common language to build a shared understanding

Using examples at multiple levels

Collaborate to discover requirements and identify uncertainty

The essence of BDD

Page 6: BDD Anti-patterns

bit.ly/bdd-antipatterns-draw @wakaleo

To deliver software that matters

And a common language to build a shared understanding

Using examples at multiple levels

Collaborate to discover requirements and identify uncertainty

The essence of BDD

Page 7: BDD Anti-patterns

bit.ly/bdd-antipatterns-draw @wakaleo

To deliver software that matters

And a common language to build a shared understanding

Using examples at multiple levels

Collaborate to discover requirements and identify uncertainty

The essence of BDD

Page 8: BDD Anti-patterns

bit.ly/bdd-antipatterns-draw @wakaleo

4

Page 9: BDD Anti-patterns

bit.ly/bdd-antipatterns-draw @wakaleo

5

Page 10: BDD Anti-patterns

bit.ly/bdd-antipatterns-draw @wakaleo

6

Page 11: BDD Anti-patterns

bit.ly/bdd-antipatterns-draw @wakaleo

7

Page 12: BDD Anti-patterns

bit.ly/bdd-antipatterns-draw @wakaleo

8

Too holey.

Too feathery.

Too scratchy.

Too straight.Too

crooked.

Too pointed…

Too patchy.

Page 13: BDD Anti-patterns

bit.ly/bdd-antipatterns-draw @wakaleo

9

Just right!

Page 14: BDD Anti-patterns

bit.ly/bdd-antipatterns-draw @wakaleo

10

Getting the balance “just right”

Page 15: BDD Anti-patterns

bit.ly/bdd-antipatterns-draw @wakaleo

10

Getting the balance “just right”

Who and When

Page 16: BDD Anti-patterns

bit.ly/bdd-antipatterns-draw @wakaleo

10

Getting the balance “just right”

Who and When

What

Page 17: BDD Anti-patterns

bit.ly/bdd-antipatterns-draw @wakaleo

10

Getting the balance “just right”

Who and When

What

How

Page 18: BDD Anti-patterns

bit.ly/bdd-antipatterns-draw @wakaleo

11

Getting the balance “just right”

Who and When

What

How

Page 19: BDD Anti-patterns

bit.ly/bdd-antipatterns-draw @wakaleo

“Out to lunch”Antipattern #1

Page 20: BDD Anti-patterns

bit.ly/bdd-antipatterns-draw @wakaleo

“The case of the disengaged stakeholder”

13

Page 21: BDD Anti-patterns

bit.ly/bdd-antipatterns-draw @wakaleo

“The case of the disengaged stakeholder”

13

FeedbackInfrequent Often

Page 22: BDD Anti-patterns

bit.ly/bdd-antipatterns-draw @wakaleo

“The case of the disengaged stakeholder”

13Co

mm

unica

tion

focu

sTe

chnic

alBu

sines

s

FeedbackInfrequent Often

Page 23: BDD Anti-patterns

bit.ly/bdd-antipatterns-draw @wakaleo

“The case of the disengaged stakeholder”

14Co

mm

unica

tion

focu

sTe

chnic

alBu

sines

s

FeedbackInfrequent Often

Page 24: BDD Anti-patterns

bit.ly/bdd-antipatterns-draw @wakaleo

“The case of the disengaged stakeholder”

14Co

mm

unica

tion

focu

sTe

chnic

alBu

sines

s

FeedbackInfrequent Often

Disengaged

Page 25: BDD Anti-patterns

bit.ly/bdd-antipatterns-draw @wakaleo

“The case of the disengaged stakeholder”

14Co

mm

unica

tion

focu

sTe

chnic

alBu

sines

s

FeedbackInfrequent Often

Disengaged Frazzled

Page 26: BDD Anti-patterns

bit.ly/bdd-antipatterns-draw @wakaleo

“The case of the disengaged stakeholder”

14Co

mm

unica

tion

focu

sTe

chnic

alBu

sines

s

FeedbackInfrequent Often

Disengaged Frazzled

Jaded

Page 27: BDD Anti-patterns

bit.ly/bdd-antipatterns-draw @wakaleo

“The case of the disengaged stakeholder”

14Co

mm

unica

tion

focu

sTe

chnic

alBu

sines

s

FeedbackInfrequent Often

Disengaged Frazzled

Jaded Engaged

Page 28: BDD Anti-patterns

bit.ly/bdd-antipatterns-draw @wakaleo

15

Page 29: BDD Anti-patterns

bit.ly/bdd-antipatterns-draw @wakaleo

“The Cucumber Salad”Antipattern #2

Page 30: BDD Anti-patterns

“The Cucumber Salad”Feature: Display customer details As an 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 returnedScenario: Customer Profile 'Marital Status' fieldScenario: Customer Profile 'Dependents' field

Page 31: BDD Anti-patterns

“In preparing for battle I have always found that plans are useless, but planning is indispensable.”

- Dwight D. Eisenhower

18

Page 32: BDD Anti-patterns

19

Planning and Requirements discovery - it’s a team sport

Page 33: BDD Anti-patterns

19

Planning and Requirements discovery - it’s a team sport

Feature Mapping

Page 34: BDD Anti-patterns

19

Planning and Requirements discovery - it’s a team sport

Feature Mapping

Story Mapping

Page 35: BDD Anti-patterns

19

Planning and Requirements discovery - it’s a team sport

Feature Mapping

Story Mapping

Example Mapping

Page 36: BDD Anti-patterns

19

Planning and Requirements discovery - it’s a team sport

Feature Mapping

Story Mapping

Example Mapping

Pairing…

Page 37: BDD Anti-patterns

bit.ly/bdd-antipatterns-draw @wakaleo

20

Page 38: BDD Anti-patterns

bit.ly/bdd-antipatterns-draw @wakaleo

“BDD Test Scripts”Antipattern #3

Page 39: BDD Anti-patterns

bit.ly/bdd-antipatterns-draw @wakaleo

“BDD test scripts”

22

Page 40: BDD Anti-patterns

bit.ly/bdd-antipatterns-draw @wakaleo

“Cucumber test scripts”

23

Page 41: BDD Anti-patterns

bit.ly/bdd-antipatterns-draw @wakaleo

24

Getting the balance “just right”

Who and When

What

How

Page 42: BDD Anti-patterns

bit.ly/bdd-antipatterns-draw @wakaleo

“Aimless requirements”Antipattern #4

Page 43: BDD Anti-patterns

“Aimless requirements”Feature: Display customer details As a user I want to view the customer's profile details So that I can see the personal information on the customer

Page 44: BDD Anti-patterns

“Aimless requirements”Feature: Display customer details As a user I want to view the customer's profile details So that I can see the personal information on the customer

Page 45: BDD Anti-patterns

“Aimless requirements”Feature: Display customer details As a user I want to view the customer's profile details So that I can see the personal information on the customer

Feature: Locate a customerIn order to propose more relevant services to my customersAs a financial adviserI want to access relevant customer's profile details

Page 46: BDD Anti-patterns

“Aimless requirements”Feature: Display customer details As a user I want to view the customer's profile details So that I can see the personal information on the customer

Feature: Locate a customerIn order to propose more relevant services to my customersAs a financial adviserI want to access relevant customer's profile details

In order to propose more relevant services to my customers

What is the real business goal?

Page 47: BDD Anti-patterns

“Aimless requirements”Feature: Display customer details As a user I want to view the customer's profile details So that I can see the personal information on the customer

Feature: Locate a customerIn order to propose more relevant services to my customersAs a financial adviserI want to access relevant customer's profile detailsAs a financial adviser

What is the real business goal?

What is the context of the user who needs this feature?

Page 48: BDD Anti-patterns

“Aimless requirements”Feature: Display customer details As a user I want to view the customer's profile details So that I can see the personal information on the customer

Feature: Locate a customerIn order to propose more relevant services to my customersAs a financial adviserI want to access relevant customer's profile details

What is the real business goal?

What is the context of the user who needs this feature?

Page 49: BDD Anti-patterns

“Aimless requirements”Feature: Display customer details As a user I want to view the customer's profile details So that I can see the personal information on the customer

Feature: Locate a customerIn order to propose more relevant services to my customersAs a financial adviserI want to access relevant customer's profile details

What is the real business goal?

What capability will help me achieve this?

I want to access relevant customer's profile details

What is the context of the user who needs this feature?

Page 50: BDD Anti-patterns

bit.ly/bdd-antipatterns-draw @wakaleo

“No shit Sherlock”Antipattern #5

Page 51: BDD Anti-patterns

bit.ly/bdd-antipatterns-draw @wakaleo

“Boring scenarios”

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 |

Page 52: BDD Anti-patterns

bit.ly/bdd-antipatterns-draw @wakaleo

“Boring scenarios”

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 |

UX concerns

Page 53: BDD Anti-patterns

bit.ly/bdd-antipatterns-draw @wakaleo

“Boring scenarios”

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 |

UX concerns

OK, but what else?

Page 54: BDD Anti-patterns

bit.ly/bdd-antipatterns-draw @wakaleo

“Scenario overload”Antipattern #6

Page 55: BDD Anti-patterns

bit.ly/bdd-antipatterns-draw @wakaleo

“Scenario overload”

30

Page 56: BDD Anti-patterns

bit.ly/bdd-antipatterns-draw @wakaleo

“Scenario overload”

30

Lots of UI steps obscure the intent

Page 57: BDD Anti-patterns

bit.ly/bdd-antipatterns-draw @wakaleo

“Scenario overload”

30

Lots of UI steps obscure the intent

And I update the billing code from ‘misc’ to ‘sadfsc’

Capture the business intent of the action

Page 58: BDD Anti-patterns

bit.ly/bdd-antipatterns-draw @wakaleo

“Scenario overload”

31

Scenario: The account earns 4% interest when the balance is over $10000 Given a bonus saver account with a end-of-month balance of 12000 When interest is calculated Then the monthly interest earned should be 40Scenario: The account earns 2% interest when the balance is less than $10000 Given a bonus saver account with a end-of-month balance of 9000 When interest is calculated Then the monthly interest earned should be 15Scenario: The account earns 4% interest when the balance is over $10000 and no more than $300 has been withdrawn Given a bonus saver account with a end-of-month balance of 12000 And a previous end-of-month balance of $12300 When interest is calculated Then the monthly interest earned should be 40Scenario: The account earns 2% interest when the balance is over $10000 and more than $300 has been withdrawn Given a bonus saver account with a end-of-month balance of 12000 And a previous end-of-month balance of $12400 When interest is calculated Then the monthly interest earned should be 15

Page 59: BDD Anti-patterns

bit.ly/bdd-antipatterns-draw @wakaleo

“Scenario overload”

31

Scenario: The account earns 4% interest when the balance is over $10000 Given a bonus saver account with a end-of-month balance of 12000 When interest is calculated Then the monthly interest earned should be 40Scenario: The account earns 2% interest when the balance is less than $10000 Given a bonus saver account with a end-of-month balance of 9000 When interest is calculated Then the monthly interest earned should be 15Scenario: The account earns 4% interest when the balance is over $10000 and no more than $300 has been withdrawn Given a bonus saver account with a end-of-month balance of 12000 And a previous end-of-month balance of $12300 When interest is calculated Then the monthly interest earned should be 40Scenario: The account earns 2% interest when the balance is over $10000 and more than $300 has been withdrawn Given a bonus saver account with a end-of-month balance of 12000 And a previous end-of-month balance of $12400 When interest is calculated Then the monthly interest earned should be 15

Scattered data hides the information

Page 60: BDD Anti-patterns

bit.ly/bdd-antipatterns-draw @wakaleo

“Scenario overload”

32

Page 61: BDD Anti-patterns

bit.ly/bdd-antipatterns-draw @wakaleo

“Scenario overload”

32

Scenario Outline: Bonus saver account Given a bonus saver account with an end-of-month balance of <balance> And a previous end-of-month balance of <previous> When the interest is calculated Then the applicable interest rate should be <rate> And <interest-earned> should be deposited into the account

Examples: balance | previous | rate| earned| rule 10000 | 10000 | 4 | 33.33 | 9000 | 9000 | 2 | 15.00 | Under 10000 earns 2% 10000 | 10300 | 4 | 33.33 | Over 10000 earns 4% 9000 | 9301 | 1 | 7.5 | Under $10000 with over 300 withdrawn earns 1% 10000 | 10301 | 2 | 16.67 | Over $10000 with over $300 withdraw earns 2%

Page 62: BDD Anti-patterns

bit.ly/bdd-antipatterns-draw @wakaleo

“Scenario overload”

32

Scenario Outline: Bonus saver account Given a bonus saver account with an end-of-month balance of <balance> And a previous end-of-month balance of <previous> When the interest is calculated Then the applicable interest rate should be <rate> And <interest-earned> should be deposited into the account

Examples: balance | previous | rate| earned| rule 10000 | 10000 | 4 | 33.33 | 9000 | 9000 | 2 | 15.00 | Under 10000 earns 2% 10000 | 10300 | 4 | 33.33 | Over 10000 earns 4% 9000 | 9301 | 1 | 7.5 | Under $10000 with over 300 withdrawn earns 1% 10000 | 10301 | 2 | 16.67 | Over $10000 with over $300 withdraw earns 2%

Sometimes tables are more expressive

Page 63: BDD Anti-patterns

bit.ly/bdd-antipatterns-draw @wakaleo

“Scenario overload”

33

Page 64: BDD Anti-patterns

bit.ly/bdd-antipatterns-draw @wakaleo

“Scenario overload”

33

Scenario Outline: Bonus saver account Given a bonus saver account with an end-of-month balance of <balance> And a previous end-of-month balance of <previous-balance> When the interest is calculated Then the applicable interest rate should be <percentage-interest> And <interest-earned> should be deposited into the account Examples: balance | previous-balance | percentage | earned | 10000 | 10000 | 4 | 33.33 | 10001 | 10000 | 4 | 33.34 | 1000 | 1000 | 2 | 1.67 | 9000 | 9000 | 2 | 15.00 | 10000 | 10300 | 4 | 33.33 | 20000 | 20000 | 4 | 100 | 10000 | 10301 | 2 | 16.67 | 9000 | 9301 | 1 | 7.5 | 20000 | 20301 | 1 | 50 | 100000 | 100301 | 1 | 250 |

Page 65: BDD Anti-patterns

bit.ly/bdd-antipatterns-draw @wakaleo

“Scenario overload”

33

Scenario Outline: Bonus saver account Given a bonus saver account with an end-of-month balance of <balance> And a previous end-of-month balance of <previous-balance> When the interest is calculated Then the applicable interest rate should be <percentage-interest> And <interest-earned> should be deposited into the account Examples: balance | previous-balance | percentage | earned | 10000 | 10000 | 4 | 33.33 | 10001 | 10000 | 4 | 33.34 | 1000 | 1000 | 2 | 1.67 | 9000 | 9000 | 2 | 15.00 | 10000 | 10300 | 4 | 33.33 | 20000 | 20000 | 4 | 100 | 10000 | 10301 | 2 | 16.67 | 9000 | 9301 | 1 | 7.5 | 20000 | 20301 | 1 | 50 | 100000 | 100301 | 1 | 250 |

And sometimes they aren’t

Page 66: BDD Anti-patterns

“Scenario overload”

34

Scenario: Find a customer by various criteria Given I am logged into the application When I click Search Then I will see search criteria options to search for the customer by customer name, date of birth, and account number

Page 67: BDD Anti-patterns

“Scenario overload”

34

Scenario: Find a customer by various criteria Given I am logged into the application When I click Search Then I will see search criteria options to search for the customer by customer name, date of birth, and account number

This is not a business outcome

Page 68: BDD Anti-patterns

“Scenario overload”

34

Scenario: Find a customer by various criteria Given I am logged into the application When I click Search Then I will see search criteria options to search for the customer by customer name, date of birth, and account number

Scenario: Find a customer by name Given the following customers exist: | id | first name | last name | | 100 | Sarah-Jane | Smith | | 101 | Sarah | Smith | When I search for a customer using the following search criteria: | name | Sarah-Jane Smith | Then I should display the following customer: | id | first name | last name | | 100 | Sarah-Jane | Smith |

This is not a business outcome

Page 69: BDD Anti-patterns

“Scenario overload”

34

Scenario: Find a customer by various criteria Given I am logged into the application When I click Search Then I will see search criteria options to search for the customer by customer name, date of birth, and account number

Scenario: Find a customer by name Given the following customers exist: | id | first name | last name | | 100 | Sarah-Jane | Smith | | 101 | Sarah | Smith | When I search for a customer using the following search criteria: | name | Sarah-Jane Smith | Then I should display the following customer: | id | first name | last name | | 100 | Sarah-Jane | Smith |

Well-defined inputs

This is not a business outcome

Page 70: BDD Anti-patterns

“Scenario overload”

34

Scenario: Find a customer by various criteria Given I am logged into the application When I click Search Then I will see search criteria options to search for the customer by customer name, date of birth, and account number

Scenario: Find a customer by name Given the following customers exist: | id | first name | last name | | 100 | Sarah-Jane | Smith | | 101 | Sarah | Smith | When I search for a customer using the following search criteria: | name | Sarah-Jane Smith | Then I should display the following customer: | id | first name | last name | | 100 | Sarah-Jane | Smith |

Well-defined inputs

Well-defined outcomes

This is not a business outcome

Page 71: BDD Anti-patterns

bit.ly/bdd-antipatterns-draw @wakaleo

35

Getting the balance “just right”

Who and When

What

How

Page 72: BDD Anti-patterns

bit.ly/bdd-antipatterns-draw @wakaleo

“Eyes on the screen”Antipattern #7

Page 73: BDD Anti-patterns

bit.ly/bdd-antipatterns-draw @wakaleo

“Eyes on the screen”

37

Scenario: User logs on to application Given I am an authorised user When I enter ‘scott’ into the username field And I enter ‘tiger’ into the password field And I click on ‘login’ Then the application home page should open

Page 74: BDD Anti-patterns

bit.ly/bdd-antipatterns-draw @wakaleo

“Eyes on the screen”

37

Scenario: User logs on to application Given I am an authorised user When I enter ‘scott’ into the username field And I enter ‘tiger’ into the password field And I click on ‘login’ Then the application home page should open

Scenario: User logs on to applicationGiven I am an authorised user When I login with a valid username and password Then I should be provided access to my accounts

Page 75: BDD Anti-patterns

bit.ly/bdd-antipatterns-draw @wakaleo

“Eyes on the screen”

37

Scenario: User logs on to application Given I am an authorised user When I enter ‘scott’ into the username field And I enter ‘tiger’ into the password field And I click on ‘login’ Then the application home page should open

Scenario: User logs on to applicationGiven I am an authorised user When I login with a valid username and password Then I should be provided access to my accountsWhen I login with a valid username and password

Page 76: BDD Anti-patterns

bit.ly/bdd-antipatterns-draw @wakaleo

“Eyes on the screen”

37

Scenario: User logs on to application Given I am an authorised user When I enter ‘scott’ into the username field And I enter ‘tiger’ into the password field And I click on ‘login’ Then the application home page should open

Scenario: User logs on to applicationGiven I am an authorised user When I login with a valid username and password Then I should be provided access to my accountsThen I should be provided access to my accounts

Page 77: BDD Anti-patterns

bit.ly/bdd-antipatterns-draw @wakaleo

“Eyes on the screen”

37

Scenario: User logs on to application Given I am an authorised user When I enter ‘scott’ into the username field And I enter ‘tiger’ into the password field And I click on ‘login’ Then the application home page should open

Scenario: User logs on to applicationGiven I am an authorised user When I login with a valid username and password Then I should be provided access to my accounts

Page 78: BDD Anti-patterns

bit.ly/bdd-antipatterns-draw @wakaleo

“Top-heavy scenarios”Antipattern #8

Page 79: BDD Anti-patterns

bit.ly/bdd-antipatterns-draw @wakaleo

“Know your audience”Antipattern #9

Page 80: BDD Anti-patterns

“Know your audience”

40

Scenario: Propose user branch when user logs in Given I am an authorised staff member When I log on using my valid credentials Then the following branches should be available in the branch drop-down | Branch name | | George Street | | Market Street | | Liverpool Street |

Page 81: BDD Anti-patterns

“Know your audience”

41

Page 82: BDD Anti-patterns

bit.ly/bdd-antipatterns-draw @wakaleo

“Incommunicado scenarios”Antipattern #10

Page 83: BDD Anti-patterns

bit.ly/bdd-antipatterns-draw @wakaleo

43

Communicate in business terms

Page 84: BDD Anti-patterns

bit.ly/bdd-antipatterns-draw @wakaleo

43

Communicate in business terms

…at a high level

Page 85: BDD Anti-patterns

bit.ly/bdd-antipatterns-draw @wakaleo

44

Communicate in business terms

Page 86: BDD Anti-patterns

bit.ly/bdd-antipatterns-draw @wakaleo

44

Communicate in business terms

…and at a detailed level

Page 87: BDD Anti-patterns

bit.ly/bdd-antipatterns-draw @wakaleo

45

So strive to get your balance “just right”

Questions?

John Ferguson [email protected]

http://www.wakaleo.com