83
Behavior Driven Development & Specification by Example Arnauld Loyer - @aloyer With S

Behavior Driven Development // Brown Bag Lunch v1.0.0

Embed Size (px)

DESCRIPTION

BDD - 101

Citation preview

Page 1: Behavior Driven Development // Brown Bag Lunch  v1.0.0

Behavior Driven Development

&

Specification by Example

Arnauld Loyer - @aloyer

With

S

Page 2: Behavior Driven Development // Brown Bag Lunch  v1.0.0

Arnauld Loyer

@aloyer Software Craftsman

BDD fan bo

y

Authentic Developer

since 2000!

@aloyer

Page 3: Behavior Driven Development // Brown Bag Lunch  v1.0.0

Exercise: Draw a 12 points Star

@aloyer

Page 4: Behavior Driven Development // Brown Bag Lunch  v1.0.0

Exercise: Draw a 12 points Star

or or

@aloyer

Page 5: Behavior Driven Development // Brown Bag Lunch  v1.0.0

"Sherlock saw the man with binoculars"

@aloyer

Page 6: Behavior Driven Development // Brown Bag Lunch  v1.0.0

Un bon cahier des charges peut être caractérisé par !les 7 qualificatifs suivants [IEEE 830]:!!

• non ambigu!• complet!• vérifiable!• consistant!• modifiable!• traçable!• utilisable durant la maintenance

Attention

ceci e

st un

e « Bulle

t Attack »

@aloyer

Page 7: Behavior Driven Development // Brown Bag Lunch  v1.0.0

Chaos Reporthttp://blog.standishgroup.com/@aloyer

Page 8: Behavior Driven Development // Brown Bag Lunch  v1.0.0

Chaos Reporthttp://blog.standishgroup.com/

Project Challenged Factors 1. Lack of User Input 12.8% 2. Incomplete Requirements & Specifications 12.3% 3. Changing Requirements & Specifications 11.8% 4. Lack of Executive Support 7.5% 5. Technology Incompetence 7.0% 6. Lack of Resources 6.4% 7. Unrealistic Expectations 5.9% 8. Unclear Objectives 5.3% 9. Unrealistic Time Frames 4.3% 10. New Technology 3.7% !Project Impaired Factors % of 1. Incomplete Requirements 13.1% 2. Lack of User Involvement 12.4% 3. Lack of Resources 10.6% 4. Unrealistic Expectations 9.9% 5. Lack of Executive Support 9.3% 6. Changing Requirements & Specifications 8.7% 7. Lack of Planning 8.1% 8. Didn't Need It Any Longer 7.5% 9. Lack of IT Management 6.2% 10. Technology Illiteracy 4.3%

Project Challenged Factors 1. Lack of User Input 12.8% 2. Incomplete Requirements & Specifications 12.3% 3. Changing Requirements & Specifications 11.8% 4. Lack of Executive Support 7.5% 5. Technology Incompetence 7.0% 6. Lack of Resources 6.4% 7. Unrealistic Expectations 5.9% 8. Unclear Objectives 5.3% 9. Unrealistic Time Frames 4.3% 10. New Technology 3.7% !Project Impaired Factors % of 1. Incomplete Requirements 13.1% 2. Lack of User Involvement 12.4% 3. Lack of Resources 10.6% 4. Unrealistic Expectations 9.9% 5. Lack of Executive Support 9.3% 6. Changing Requirements & Specifications 8.7% 7. Lack of Planning 8.1% 8. Didn't Need It Any Longer 7.5% 9. Lack of IT Management 6.2% 10. Technology Illiteracy 4.3%

Project Challenged Factors 1. Lack of User Input 12.8% 2. Incomplete Requirements & Specifications 12.3% 3. Changing Requirements & Specifications 11.8% 4. Lack of Executive Support 7.5% 5. Technology Incompetence 7.0% 6. Lack of Resources 6.4% 7. Unrealistic Expectations 5.9% 8. Unclear Objectives 5.3% 9. Unrealistic Time Frames 4.3% 10. New Technology 3.7% !Project Impaired Factors % of 1. Incomplete Requirements 13.1% 2. Lack of User Involvement 12.4% 3. Lack of Resources 10.6% 4. Unrealistic Expectations 9.9% 5. Lack of Executive Support 9.3% 6. Changing Requirements & Specifications 8.7% 7. Lack of Planning 8.1% 8. Didn't Need It Any Longer 7.5% 9. Lack of IT Management 6.2% 10. Technology Illiteracy 4.3%

@aloyer

Page 9: Behavior Driven Development // Brown Bag Lunch  v1.0.0

The Bull Survey (1998) !All the managers interviewed had previously taken the lead in integrating large systems within organizations in the Times Top 100.!!Project Evaluation Criteria !The main IT project failure criteria identified by the IT and project managers were:!* missed deadlines (75%)!* exceeded budget (55%)!* poor communications (40%)!* inability to meet project requirements (37%).!!http://www.it-cortex.com/Stat_Failure_Cause.htm

@aloyer

Page 10: Behavior Driven Development // Brown Bag Lunch  v1.0.0

The Bull Survey (1998) !All the managers interviewed had previously taken the lead in integrating large systems within organizations in the Times Top 100.!!Project Evaluation Criteria !The main IT project failure criteria identified by the IT and project managers were:!* missed deadlines (75%)!* exceeded budget (55%)!* poor communications (40%)!* inability to meet project requirements (37%).!!http://www.it-cortex.com/Stat_Failure_Cause.htm

2005 Survey: The Top Challenges Facing Business Analysts

Business Improvement Architect’s research survey of Business Analysts attending Project World/

Business Analyst World 2005 in Toronto, Canada, identified that ‘Lack of Clarity in the Scope of

the Business Functions’ and ‘Business Requirements Not Well-Defined” are the top two

challenges facing their organizations in managing business requirements.!

!-- http://www.bia.ca/articles/TheTopChallengesFacingBusinessAnalysts.htm

@aloyer

Page 11: Behavior Driven Development // Brown Bag Lunch  v1.0.0

The Bull Survey (1998) !All the managers interviewed had previously taken the lead in integrating large systems within organizations in the Times Top 100.!!Project Evaluation Criteria !The main IT project failure criteria identified by the IT and project managers were:!* missed deadlines (75%)!* exceeded budget (55%)!* poor communications (40%)!* inability to meet project requirements (37%).!!http://www.it-cortex.com/Stat_Failure_Cause.htm

2005 Survey: The Top Challenges Facing Business Analysts

Business Improvement Architect’s research survey of Business Analysts attending Project World/

Business Analyst World 2005 in Toronto, Canada, identified that ‘Lack of Clarity in the Scope of

the Business Functions’ and ‘Business Requirements Not Well-Defined” are the top two

challenges facing their organizations in managing business requirements.!

!-- http://www.bia.ca/articles/TheTopChallengesFacingBusinessAnalysts.htm

Why IT Projects Fail

1. Lack of Governance!

2. Internal Politics!

3. Poor communication between business and IT!

4. Unclear expectations!

! http://www.itbusinessedge.com/slideshows/show.aspx?c=81818&slide=4

@aloyer

Page 12: Behavior Driven Development // Brown Bag Lunch  v1.0.0

The Bull Survey (1998) !All the managers interviewed had previously taken the lead in integrating large systems within organizations in the Times Top 100.!!Project Evaluation Criteria !The main IT project failure criteria identified by the IT and project managers were:!* missed deadlines (75%)!* exceeded budget (55%)!* poor communications (40%)!* inability to meet project requirements (37%).!!http://www.it-cortex.com/Stat_Failure_Cause.htm

2005 Survey: The Top Challenges Facing Business Analysts

Business Improvement Architect’s research survey of Business Analysts attending Project World/

Business Analyst World 2005 in Toronto, Canada, identified that ‘Lack of Clarity in the Scope of

the Business Functions’ and ‘Business Requirements Not Well-Defined” are the top two

challenges facing their organizations in managing business requirements.!

!-- http://www.bia.ca/articles/TheTopChallengesFacingBusinessAnalysts.htm

Why IT Projects Fail

1. Lack of Governance!

2. Internal Politics!

3. Poor communication between business and IT!

4. Unclear expectations!

! http://www.itbusinessedge.com/slideshows/show.aspx?c=81818&slide=4

Why Software Fails - We waste billions of dollars each year on entirely preventable mistakes

(2005)!

http://spectrum.ieee.org/computing/software/why-software-fails!

!Among the most common factors:!

* Unrealistic or unarticulated project goals!

* Inaccurate estimates of needed resources!

* Badly defined system requirements!

* Poor reporting of the project's status!

* Unmanaged risks!

* Poor communication among customers, developers, and users!

* Use of immature technology!

* Inability to handle the project's complexity!

* Sloppy development practices!

* Poor project management!

* Stakeholder politics!

* Commercial pressures

@aloyer

Page 13: Behavior Driven Development // Brown Bag Lunch  v1.0.0

The Bull Survey (1998) !All the managers interviewed had previously taken the lead in integrating large systems within organizations in the Times Top 100.!!Project Evaluation Criteria !The main IT project failure criteria identified by the IT and project managers were:!* missed deadlines (75%)!* exceeded budget (55%)!* poor communications (40%)!* inability to meet project requirements (37%).!!http://www.it-cortex.com/Stat_Failure_Cause.htm

2005 Survey: The Top Challenges Facing Business Analysts

Business Improvement Architect’s research survey of Business Analysts attending Project World/

Business Analyst World 2005 in Toronto, Canada, identified that ‘Lack of Clarity in the Scope of

the Business Functions’ and ‘Business Requirements Not Well-Defined” are the top two

challenges facing their organizations in managing business requirements.!

!-- http://www.bia.ca/articles/TheTopChallengesFacingBusinessAnalysts.htm

Why IT Projects Fail

1. Lack of Governance!

2. Internal Politics!

3. Poor communication between business and IT!

4. Unclear expectations!

! http://www.itbusinessedge.com/slideshows/show.aspx?c=81818&slide=4

Why Software Fails - We waste billions of dollars each year on entirely preventable mistakes

(2005)!

http://spectrum.ieee.org/computing/software/why-software-fails!

!Among the most common factors:!

* Unrealistic or unarticulated project goals!

* Inaccurate estimates of needed resources!

* Badly defined system requirements!

* Poor reporting of the project's status!

* Unmanaged risks!

* Poor communication among customers, developers, and users!

* Use of immature technology!

* Inability to handle the project's complexity!

* Sloppy development practices!

* Poor project management!

* Stakeholder politics!

* Commercial pressures

Seven Reasons IT Projects Fail - February 2012 !1. Poor Project Planning and Direction 2. Insufficient Communication 3. Ineffective Management 4. Failure to Align With Constituents and Stakeholders !

http://www.ibmsystemsmag.com/power/Systems-Management/Workload-Management/project_pitfalls/?page=2!

@aloyer

Page 14: Behavior Driven Development // Brown Bag Lunch  v1.0.0

The Bull Survey (1998) !All the managers interviewed had previously taken the lead in integrating large systems within organizations in the Times Top 100.!!Project Evaluation Criteria !The main IT project failure criteria identified by the IT and project managers were:!* missed deadlines (75%)!* exceeded budget (55%)!* poor communications (40%)!* inability to meet project requirements (37%).!!http://www.it-cortex.com/Stat_Failure_Cause.htm

2005 Survey: The Top Challenges Facing Business Analysts

Business Improvement Architect’s research survey of Business Analysts attending Project World/

Business Analyst World 2005 in Toronto, Canada, identified that ‘Lack of Clarity in the Scope of

the Business Functions’ and ‘Business Requirements Not Well-Defined” are the top two

challenges facing their organizations in managing business requirements.!

!-- http://www.bia.ca/articles/TheTopChallengesFacingBusinessAnalysts.htm

Why IT Projects Fail

1. Lack of Governance!

2. Internal Politics!

3. Poor communication between business and IT!

4. Unclear expectations!

! http://www.itbusinessedge.com/slideshows/show.aspx?c=81818&slide=4

Why Software Fails - We waste billions of dollars each year on entirely preventable mistakes

(2005)!

http://spectrum.ieee.org/computing/software/why-software-fails!

!Among the most common factors:!

* Unrealistic or unarticulated project goals!

* Inaccurate estimates of needed resources!

* Badly defined system requirements!

* Poor reporting of the project's status!

* Unmanaged risks!

* Poor communication among customers, developers, and users!

* Use of immature technology!

* Inability to handle the project's complexity!

* Sloppy development practices!

* Poor project management!

* Stakeholder politics!

* Commercial pressures

Seven Reasons IT Projects Fail - February 2012 !1. Poor Project Planning and Direction 2. Insufficient Communication 3. Ineffective Management 4. Failure to Align With Constituents and Stakeholders !

http://www.ibmsystemsmag.com/power/Systems-Management/Workload-Management/project_pitfalls/?page=2!

The Most Common Factors for the failure of Software Development Project !1. Lack of Customer or User Involvement 2. Unclear goals and objectives 3. Poor Requirement Set 4. Lack of Resources 5. Failure to communicate and act as a team !!

Volume 1, No. 11, January 2013 ISSN – 2278-1080 !The International Journal of Computer Science & Applications!http://www.journalofcomputerscience.com/2013Issue/Jan13/V1No11Jan13P044.pdf

@aloyer

Page 15: Behavior Driven Development // Brown Bag Lunch  v1.0.0

I want

« A »A

BDD in 5 minutes 10@aloyer

Page 16: Behavior Driven Development // Brown Bag Lunch  v1.0.0

I want

« A »Let’s Specify

« B » A

BDD in 5 minutes 10@aloyer

Page 17: Behavior Driven Development // Brown Bag Lunch  v1.0.0

I want

« A »Let’s Specify

« B »

B

A

BDD in 5 minutes 10@aloyer

Page 18: Behavior Driven Development // Brown Bag Lunch  v1.0.0

I want

« A »

I Will Test

« C »

C

B

A

Let’s Specify

« B »

11BDD in 5 minutes 11

Page 19: Behavior Driven Development // Brown Bag Lunch  v1.0.0

BDD in 5 minutes 12

I want

« A »

I Will Test

« C »

Let’s Develop

« D »

D

C

B

A

Let’s Specify

« B »

Page 20: Behavior Driven Development // Brown Bag Lunch  v1.0.0

D

C

B

A

Developed

Specified

Tested

Wanted

13BDD in 5 minutes 13

Page 21: Behavior Driven Development // Brown Bag Lunch  v1.0.0

D

C

B

A

Developed

Specified

Tested

Wanted

Humpff

13BDD in 5 minutes 13

Page 22: Behavior Driven Development // Brown Bag Lunch  v1.0.0

BDD in 5 minutes 14

Page 23: Behavior Driven Development // Brown Bag Lunch  v1.0.0

BDD in 5 minutes 14

NooOOOOooo!!

Page 24: Behavior Driven Development // Brown Bag Lunch  v1.0.0

"is this a bug or is this not a

bug?"

a bug?

a feature?

an enhancement?

a beature?

Page 25: Behavior Driven Development // Brown Bag Lunch  v1.0.0

@aloyer

Page 26: Behavior Driven Development // Brown Bag Lunch  v1.0.0

@aloyer

Page 27: Behavior Driven Development // Brown Bag Lunch  v1.0.0

@aloyer

Page 28: Behavior Driven Development // Brown Bag Lunch  v1.0.0

3 steps

3 models

3 interpretations

@aloyer

Page 29: Behavior Driven Development // Brown Bag Lunch  v1.0.0

3 steps

3 models

3 interpretations

@aloyer

Page 30: Behavior Driven Development // Brown Bag Lunch  v1.0.0

3 visions

1 model

1 goal

@aloyer

Page 31: Behavior Driven Development // Brown Bag Lunch  v1.0.0

Working together to find better solutions

Use real-world examples to build a shared understanding of the domain

People understand requirements best using concrete examples.

Examples clear up ambiguity and misunderstandings.

Examples expose missing requirements.

Examples force everyone to think harder about a problem.

@aloyer

Page 32: Behavior Driven Development // Brown Bag Lunch  v1.0.0

Test

First

Test

Driven

Develo

pmen

t

Behav

ior Driv

en Dev

elopm

ent!

« 200

3 » Execu

table

Specifi

catio

n!

& Automati

on

Explor

atory

Example

s!

& Discus

sion

@aloyer

Page 33: Behavior Driven Development // Brown Bag Lunch  v1.0.0

http://pencilink.blogspot.fr/2010/10/iron-man-160-jim-starlin-cover-steve.html

It’s NOT about tools

@aloyer

Page 34: Behavior Driven Development // Brown Bag Lunch  v1.0.0

http://pencilink.blogspot.fr/2010/10/iron-man-160-jim-starlin-cover-steve.html

It’s NOT about tools

It’s about Communication and Behavior!

@aloyer

Page 35: Behavior Driven Development // Brown Bag Lunch  v1.0.0

http://ungoliantschilde.tumblr.com/post/78793890826/ungoliantschilde-barry-windsor-smith-that

It’s NOT about Testing

@aloyer

Page 36: Behavior Driven Development // Brown Bag Lunch  v1.0.0

http://ungoliantschilde.tumblr.com/post/78793890826/ungoliantschilde-barry-windsor-smith-that

It’s NOT about Testing

It’s about Exploring the Unknown

@aloyer

Page 37: Behavior Driven Development // Brown Bag Lunch  v1.0.0

It’s not about Silo!Or Acceptance

Criteria

@aloyer

Page 38: Behavior Driven Development // Brown Bag Lunch  v1.0.0

It’s not about Silo!Or Acceptance

Criteria

It’s about

Sharing

and

Understanding

@aloyer

Page 39: Behavior Driven Development // Brown Bag Lunch  v1.0.0

It’s about Driven Development!

@aloyer

Page 40: Behavior Driven Development // Brown Bag Lunch  v1.0.0

Examples Tests

Requirements

elaborate

can become

verify

@aloyer

Page 41: Behavior Driven Development // Brown Bag Lunch  v1.0.0

Three Amigos

Page 42: Behavior Driven Development // Brown Bag Lunch  v1.0.0

@aloyer

Page 43: Behavior Driven Development // Brown Bag Lunch  v1.0.0

BDD is about conversation

@aloyer

Page 44: Behavior Driven Development // Brown Bag Lunch  v1.0.0

BDD is about conversation

BDD is not about tools

@aloyer

Page 45: Behavior Driven Development // Brown Bag Lunch  v1.0.0

@aloyer

Page 46: Behavior Driven Development // Brown Bag Lunch  v1.0.0

What?

How!

@aloyer

Page 47: Behavior Driven Development // Brown Bag Lunch  v1.0.0

Why?

Goal?

Business Value?

What?

How!

@aloyer

Page 48: Behavior Driven Development // Brown Bag Lunch  v1.0.0

Why?

Goal?

Business Value?

IntentionWhat?

How!

@aloyer

Page 49: Behavior Driven Development // Brown Bag Lunch  v1.0.0

29

Page 50: Behavior Driven Development // Brown Bag Lunch  v1.0.0

Why?

Goal?

Business Value?

In order to <achieve the vision>

Feature: ...

As a <stakeholder>I want <value>

IntentionWhat?

How!

@aloyer

Page 51: Behavior Driven Development // Brown Bag Lunch  v1.0.0

Why?

Goal?

Business Value?

In order to <achieve the vision>

Feature: ...

As a <stakeholder>I want <value>

Intention

As a <role>I want <goal>So that <value>

User focused

What?

How!

@aloyer

Page 52: Behavior Driven Development // Brown Bag Lunch  v1.0.0

No Narrative

No Business Value

Unnecessary Feature !

@aloyer

Page 53: Behavior Driven Development // Brown Bag Lunch  v1.0.0

Feature

Criteria!(Rules)

Criteria!(Rules)

What is it supposed to do

Example

Example

Example

Example

Illustration of

Acceptance Criteria vs Example @aloyer 32

Example

Page 54: Behavior Driven Development // Brown Bag Lunch  v1.0.0

Examples of Examples @aloyer 33

Password OK/KO Reason

Arn4uld KO No special characters

arnauld$ KO No upper case

Arn4ld$ OK

Z0€ KO too short

Last Passwords Password OK/KO

J0hn$!$m1th!

Arn4ld$Arn4ld$ KO

J0hn$!Arn4ld$!$m1th

Arn4ld$ KO

Arn4ld$!J0hn$!$m1th

Arn4ld$ OK

Page 55: Behavior Driven Development // Brown Bag Lunch  v1.0.0

In order to...Feature: ...

As a...I want to...Scenario: ...

@aloyer

Page 56: Behavior Driven Development // Brown Bag Lunch  v1.0.0

In order to...Feature: ...

As a...I want to...Scenario: ...Given <a context>When <an event happens>Then <an outcome should occur>

@aloyer

Page 57: Behavior Driven Development // Brown Bag Lunch  v1.0.0

In order to...Feature: ...

As a...I want to...Scenario: ...Given <a context>When <an event happens>Then <an outcome should occur>

BDD uses examples to illustrate

behavior

@aloyer

Page 58: Behavior Driven Development // Brown Bag Lunch  v1.0.0

Gherkin - Scenario - Given/When/Then

Scenario: Some determinable business situation

When <an action is performed on the system>Then <an expected outcome should be observed>

Given <a specific context>

Every scenario consists of a list of steps

35

Resulting!StateInitial!Context

Given

Given

Given

Given

When

ThenWhen

Then

Then

Transition@aloyer

Page 59: Behavior Driven Development // Brown Bag Lunch  v1.0.0

Gherkin - Scenario - Given/When/Then

Given!!The purpose of givens is to put the system in a known state before interacting with it. They defines the preconditions. !• Indicate which environment to use • Insert values in database • Fill context with predefined users • Log user • …

Given there are no users on site!Given the database is clean Given the predefined high and volatile stocks Given I am logged in as "Balthazar"

36@aloyer

Page 60: Behavior Driven Development // Brown Bag Lunch  v1.0.0

Gherkin - Scenario - Given/When/Then

When!!The purpose of when steps is to describe the key action performed (the state transition). !• Trigger commands • Interact with the UI • Go to a specific page, Fill a form, Select books or CDs • Launch a batch • …

When I log in the application as "Gaspard" When I look at my profile!When I book the deal When I generate the financial report

37@aloyer

Page 61: Behavior Driven Development // Brown Bag Lunch  v1.0.0

Gherkin - Scenario - Given/When/Then

Then!!The purpose of Then steps is to observe outcomes. The observations should be related to the business value/benefit of the feature. !• Feedback message • Generated document, Mail sent • Command output • Data updated • …

It should be something related to

the Given/When

Then I should see a welcome message Then the report should contain the created deal!Then the result should be 42

39@aloyer

Page 62: Behavior Driven Development // Brown Bag Lunch  v1.0.0

Why do YOU

like should?

It encourages

debate, and

constant Questioning

of the premise of the

application you are

developing.

Dan North, March 2005

DMZ

BDD Approach

40Gherkin - Should 40@aloyer

Page 63: Behavior Driven Development // Brown Bag Lunch  v1.0.0

Gherkin - Scenario - Given/When/Then

Scenario: Some determinable business situation !

Given a specific context Given another specific context Given an even other specific context When an action is performed on the system When another action is performed on the system Then expected outcome Then an other expected outcome Then an even other expected outcome

41@aloyer

Page 64: Behavior Driven Development // Brown Bag Lunch  v1.0.0

Gherkin - Scenario - And/But

Scenario: Some determinable business situation !

Given a specific context And another specific context But an even other specific context When an action is performed on the system And another action is performed on the system Then expected outcome And an other expected outcome But an even other expected outcome

Given/When/Then + And/But

42@aloyer

Page 65: Behavior Driven Development // Brown Bag Lunch  v1.0.0

Gherkin - Sample

Feature: Trade Execution !In order to reduce the risk of other clearing firm failing to honor its trade settlement obligations As a clearing firm I want that a clearing house stands between me and the other firm

Scenario: New trade is confirmed between the bank and counterparty !

Given A new trade between the bank and counterparty When the trade is captured Then it should be sent to clearing house for matching

43@aloyer

Page 66: Behavior Driven Development // Brown Bag Lunch  v1.0.0

Gherkin - Sample

Feature: Trade Execution !In order to reduce the risk of other clearing firm failing to honor its trade settlement obligations As a clearing firm I want that a clearing house stands between me and the other firm

Scenario: New trade is confirmed between the bank and counterparty !

Given A new trade between the bank and counterparty When the trade is captured Then it should be sent to clearing house for matching

44

Must give a quick overview of what scenario is doing

@aloyer

Page 67: Behavior Driven Development // Brown Bag Lunch  v1.0.0

Gherkin - Sample Calculator Feature

Feature: Addition feature !

In order to perform mathematical operations As an accounting officer I want to be able to add numbers

45@aloyer

Page 68: Behavior Driven Development // Brown Bag Lunch  v1.0.0

Gherkin - Sample Calculator Feature 46

What could be

the first use case?

@aloyer

Page 69: Behavior Driven Development // Brown Bag Lunch  v1.0.0

Gherkin - Sample Calculator Feature

Feature: Addition feature !

In order to perform mathematical operations As an accounting officer I want to be able to add numbers !

Scenario: Addition of positive numbers !

Given two numbers 12 and 7 When I add them Then the result should be 19

47@aloyer

Page 70: Behavior Driven Development // Brown Bag Lunch  v1.0.0

Gherkin - Sample Calculator Feature

Feature: Addition feature !

In order to perform mathematical operations As an accounting officer I want to be able to add numbers !

Scenario: Addition of positive numbers !

Given two numbers 12 and 7 When I add them Then the result should be 19

47

It should be something related to

the Given/When‟

@aloyer

Page 71: Behavior Driven Development // Brown Bag Lunch  v1.0.0

Gherkin - Sample Calculator Feature

Feature: Addition feature !

In order to perform mathematical operations As an accounting officer I want to be able to add numbers !

Scenario: Addition of positive numbers !

Given two numbers 12 and 7 When I add them Then the result should be 19

48

It should be something related to

the Given/When‟Scenario: Addition of positive numbers !

Given two numbers 12 and 7 When I add them Then the result should be 23 Should Fail!

@aloyer

Page 72: Behavior Driven Development // Brown Bag Lunch  v1.0.0

Gherkin - Sample Calculator Feature 49

What could be the next

Scenario?

@aloyer

Page 73: Behavior Driven Development // Brown Bag Lunch  v1.0.0

Gherkin - Sample Calculator Feature

Feature: Addition feature !

In order to perform mathematical operations As an accounting officer I want to be able to add numbers

!Scenario: Addition of positive numbers !

Given two numbers 12 and 7 When I add them Then the result should be 19

!Scenario: Addition of a positive number and a negative number !

Given two numbers 11 and -3 When I add them Then the result should be 8

50@aloyer

Page 74: Behavior Driven Development // Brown Bag Lunch  v1.0.0

Gherkin - Sample Calculator Feature

Feature: Addition feature !

In order to perform mathematical operations As an accounting officer I want to be able to add numbers

!Scenario: Addition of positive numbers !

Given two numbers 12 and 7 When I add them Then the result should be 19

!Scenario: Addition of a positive number and a negative number !

Given two numbers 11 and -3 When I add them Then the result should be 8

51

Reusable Step

@aloyer

Page 75: Behavior Driven Development // Brown Bag Lunch  v1.0.0

Gherkin - Sample Calculator Feature

Feature: Addition feature !

In order to perform mathematical operations As an accounting officer I want to be able to add numbers

!Scenario: Addition of positive numbers !

Given two numbers 12 and 7 When I add them Then the result should be 19

!Scenario: Addition of a positive number and a negative number !

Given two numbers 11 and -3 When I add them Then the result should be 8

52

Parameterized Step

@aloyer

Page 76: Behavior Driven Development // Brown Bag Lunch  v1.0.0

@aloyer

Page 77: Behavior Driven Development // Brown Bag Lunch  v1.0.0

@aloyer

Page 78: Behavior Driven Development // Brown Bag Lunch  v1.0.0

@aloyer

Page 79: Behavior Driven Development // Brown Bag Lunch  v1.0.0

@aloyer

Page 80: Behavior Driven Development // Brown Bag Lunch  v1.0.0

In order to...Feature: ...

As a...I want to...

Scenario: ...Given <a context>When <an event happens>Then <an outcome should occur>

@aloyer

Page 81: Behavior Driven Development // Brown Bag Lunch  v1.0.0

In order to...Feature: ...

As a...I want to...

Scenario: ...Given <a context>When <an event happens>Then <an outcome should occur>

@aloyer

Page 82: Behavior Driven Development // Brown Bag Lunch  v1.0.0

In order to...Feature: ...

As a...I want to...

Scenario: ...Given <a context>When <an event happens>Then <an outcome should occur>

Examples help discover things early

@aloyer

Page 83: Behavior Driven Development // Brown Bag Lunch  v1.0.0

In order to...Feature: ...

As a...I want to...

Scenario: ...Given <a context>When <an event happens>Then <an outcome should occur>

One may discover that one doesn't know

but others do!

@aloyer