Behaviour Driven Development is a powerful collaboration technique that can empower teams to deliver higher value features to the business faster and more effectively. But although Behaviour Driven Development is based on a number of simple principles, it can go dramatically wrong in a myriad of different ways.
In this talk we discuss twelve BDD anti-patterns we frequently encounter in real-world BDD projects, anti-patterns that can dramatically reduce the effectiveness of BDD as a practice, and that can even cause BDD adoption to fail entirely. Looking at everything from insufficient collaboration practices to poor use of test automation tooling, from teams that test too much to teams that forget the most important scenarios, we will look at the many different ways that BDD can go wrong, and how it should be done.
We will use real-world examples to illustrate each of these anti-patterns. You will learn how to spot these issues in your own projects, and more importantly how to avoid them in the first place.
2. John Ferguson Smart
âI help teams of smart people âš
learn to work together more efïŹciently, âš
to deliver better software fasterâ
wakaleo john@johnfergusonsmart.com
3. 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
4. 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
5. 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
6. 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
7. 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
30. â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 returnedâš
âš
Scenario: Customer Profile 'Marital Status' fieldâš
Scenario: Customer Profile 'Dependents' field
31. âIn preparing for battle I have always found that plans are useless,
but planning is indispensable.â
- Dwight D. Eisenhower
18
43. â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
44. â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
45. â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 customerâš
In order to propose more relevant services to my customersâš
As a financial adviserâš
I want to access relevant customer's profile details
46. â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 customerâš
In order to propose more relevant services to my customersâš
As a financial adviserâš
I want to access relevant customer's profile details
In order to propose more relevant services to my customers
What is the real
business goal?
47. â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 customerâš
In order to propose more relevant services to my customersâš
As a financial adviserâš
I want to access relevant customer's profile details
As a financial adviserâš
What is the real
business goal?
What is the context of the
user who needs this feature?
48. â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 customerâš
In order to propose more relevant services to my customersâš
As a financial adviserâš
I 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?
49. â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 customerâš
In order to propose more relevant services to my customersâš
As a financial adviserâš
I 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?
51. 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 |
52. 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
53. 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?
58. 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 40âš
âš
Scenario: 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 15âš
âš
Scenario: 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 40âš
âš
Scenario: 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
59. 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 40âš
âš
Scenario: 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 15âš
âš
Scenario: 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 40âš
âš
Scenario: 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
61. 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%
62. 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
64. 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 |
65. 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
66. â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
67. â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
68. â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
69. â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-deïŹned inputs
This is not a business outcome
70. â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-deïŹned inputs
Well-deïŹned outcomes
This is not a business outcome
73. 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
74. 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 applicationâš
Given I am an authorised user
When I login with a valid username and password
Then I should be provided access to my accounts
75. 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 applicationâš
Given I am an authorised user
When I login with a valid username and password
Then I should be provided access to my accounts
When I login with a valid username and password
76. 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 applicationâš
Given 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
77. 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 applicationâš
Given I am an authorised user
When I login with a valid username and password
Then I should be provided access to my accounts
80. â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 |