hello bdd
DESCRIPTION
Introduction to BDDTRANSCRIPT
![Page 1: Hello bdd](https://reader035.vdocument.in/reader035/viewer/2022070318/55782f95d8b42a9b438b510c/html5/thumbnails/1.jpg)
Hello BDD!Hello BDD!ANTONIO ROBRES TURON
![Page 2: Hello bdd](https://reader035.vdocument.in/reader035/viewer/2022070318/55782f95d8b42a9b438b510c/html5/thumbnails/2.jpg)
Given a speaker with name Toni
When he is giving his conference
Then you should not fall asleep
![Page 3: Hello bdd](https://reader035.vdocument.in/reader035/viewer/2022070318/55782f95d8b42a9b438b510c/html5/thumbnails/3.jpg)
![Page 4: Hello bdd](https://reader035.vdocument.in/reader035/viewer/2022070318/55782f95d8b42a9b438b510c/html5/thumbnails/4.jpg)
BDD
EDD
ATDD
DDD
SPECIFICATION BY
EXAMPLE
AGILE ACCEPTANCE
TEST
EXECUTABLE
SPECIFICATIONS
STORY TELLING
![Page 5: Hello bdd](https://reader035.vdocument.in/reader035/viewer/2022070318/55782f95d8b42a9b438b510c/html5/thumbnails/5.jpg)
Index
•Why born BDD?•What is BDD?•How use BDD?•Benefits•Demo
![Page 6: Hello bdd](https://reader035.vdocument.in/reader035/viewer/2022070318/55782f95d8b42a9b438b510c/html5/thumbnails/6.jpg)
BDD HISTORY
![Page 7: Hello bdd](https://reader035.vdocument.in/reader035/viewer/2022070318/55782f95d8b42a9b438b510c/html5/thumbnails/7.jpg)
First approach
TDD Test Drive Development0 Is not a tool!!!! It’s a design methodology0 Focused in unit testing 0 Life cycle
0Red 0Green 0Refactor
0 Something is missing:0THINK!0Think Red Green Refactor
![Page 8: Hello bdd](https://reader035.vdocument.in/reader035/viewer/2022070318/55782f95d8b42a9b438b510c/html5/thumbnails/8.jpg)
TDD is fine but…
• Is programmer focused• Only take care about the source code• Helps to write code right but not right code• Not support communication0 Inside team (including QA, BA, Data analyst…)
0With stakeholders• Is bottom – up process
![Page 9: Hello bdd](https://reader035.vdocument.in/reader035/viewer/2022070318/55782f95d8b42a9b438b510c/html5/thumbnails/9.jpg)
BDD History
BDD was developed by Dan North as a response to the issues encountered teaching TDD
0 Where to start in the process0 What to test and what not to test0 How much to test in one go0 What to call the tests0 How to understand why a test fails0 Give you reliability your tests?
![Page 10: Hello bdd](https://reader035.vdocument.in/reader035/viewer/2022070318/55782f95d8b42a9b438b510c/html5/thumbnails/10.jpg)
BDD History
• The first proposes was that the unit testing names be whole sentences starting with the word SHOULD and written in order of business value.0Every class should do something
• ClientDetailsValidatorTest0ShouldFailForMissingSurname0ShouldFailForMissingAge
![Page 11: Hello bdd](https://reader035.vdocument.in/reader035/viewer/2022070318/55782f95d8b42a9b438b510c/html5/thumbnails/11.jpg)
What is BDD?
![Page 12: Hello bdd](https://reader035.vdocument.in/reader035/viewer/2022070318/55782f95d8b42a9b438b510c/html5/thumbnails/12.jpg)
Definition
• BDD is a second-generation, outside-in, pull-based, multiple-stakeholder, multiple-scale, high-automation, agile methodology. It describes a cycle of interactions with well-defined outputs, resulting in the delivery of working, tested software that matters.
• Using examples to create a shared understanding and surface uncertainly to deliver software that matters.
![Page 13: Hello bdd](https://reader035.vdocument.in/reader035/viewer/2022070318/55782f95d8b42a9b438b510c/html5/thumbnails/13.jpg)
How use BDD?
![Page 14: Hello bdd](https://reader035.vdocument.in/reader035/viewer/2022070318/55782f95d8b42a9b438b510c/html5/thumbnails/14.jpg)
Story
•What’s an story?It has to be a description of a requirement and its
business benefit, and a set of criteria by which we all agree that it is “done” (Dann North)
•Written in business language
![Page 15: Hello bdd](https://reader035.vdocument.in/reader035/viewer/2022070318/55782f95d8b42a9b438b510c/html5/thumbnails/15.jpg)
Story
• Structure:0 Title (one line describing the story)0 Narrative:
0As a [role]0 I want [feature]0So that [benefit]
![Page 16: Hello bdd](https://reader035.vdocument.in/reader035/viewer/2022070318/55782f95d8b42a9b438b510c/html5/thumbnails/16.jpg)
Story
Example:0 As a user 0 I want to publish a tweet0 So that share information with my followers
![Page 17: Hello bdd](https://reader035.vdocument.in/reader035/viewer/2022070318/55782f95d8b42a9b438b510c/html5/thumbnails/17.jpg)
Story
Another template:0 Title (one line describing the story)0 Narrative
0 In order to [benefit]0As a [role]0 I want to [feature]
![Page 18: Hello bdd](https://reader035.vdocument.in/reader035/viewer/2022070318/55782f95d8b42a9b438b510c/html5/thumbnails/18.jpg)
Story
Example:0 In order to share information with my followers0 As a user 0 I want to publish a tweet
![Page 19: Hello bdd](https://reader035.vdocument.in/reader035/viewer/2022070318/55782f95d8b42a9b438b510c/html5/thumbnails/19.jpg)
Scenario
• It’s the acceptance criteria• It’s a description of each specific case
of the narrative• Can be used to help discover the scope
of the story or the feature• The scenario should be described in
terms of Givens, Events and Outcomes
![Page 20: Hello bdd](https://reader035.vdocument.in/reader035/viewer/2022070318/55782f95d8b42a9b438b510c/html5/thumbnails/20.jpg)
Scenario
Structure:0 Title (one line describing the scenario)0 Narrative
0Given [context]0And [some more context]...0When [event]0Then [outcome]0And [another outcome]...
![Page 21: Hello bdd](https://reader035.vdocument.in/reader035/viewer/2022070318/55782f95d8b42a9b438b510c/html5/thumbnails/21.jpg)
Scenario
Example:Given a twitter account activated
When I send a tweet with 139 characters
Then the tweet is published
And all my followers can read the tweet
![Page 22: Hello bdd](https://reader035.vdocument.in/reader035/viewer/2022070318/55782f95d8b42a9b438b510c/html5/thumbnails/22.jpg)
How to build scenarios?
Only 4 keywords have the empowerment to build scenarios
0 but something is missing…
What is the most powerful tool to build the scenarios?
![Page 23: Hello bdd](https://reader035.vdocument.in/reader035/viewer/2022070318/55782f95d8b42a9b438b510c/html5/thumbnails/23.jpg)
![Page 24: Hello bdd](https://reader035.vdocument.in/reader035/viewer/2022070318/55782f95d8b42a9b438b510c/html5/thumbnails/24.jpg)
Having conversations
![Page 25: Hello bdd](https://reader035.vdocument.in/reader035/viewer/2022070318/55782f95d8b42a9b438b510c/html5/thumbnails/25.jpg)
User Story & Scenario Example
Title: Customer withdraws cashAs a customer,I want to withdraw cash from an ATM,so that I don’t have to wait in line at the bank.
Scenario 1: Account is in creditGiven the account is in creditAnd the card is validAnd the dispenser contains cashWhen the customer requests cashThen ensure the account is debitedAnd ensure cash is dispensedAnd ensure the card is returned
![Page 26: Hello bdd](https://reader035.vdocument.in/reader035/viewer/2022070318/55782f95d8b42a9b438b510c/html5/thumbnails/26.jpg)
User Story & Scenario Example
Scenario 2: Account has insufficient funds
Given the account is overdrawnAnd the card is validWhen the customer requests cashThen ensure a rejection message is displayedAnd ensure cash is not dispensedAnd ensure the card is returned
![Page 27: Hello bdd](https://reader035.vdocument.in/reader035/viewer/2022070318/55782f95d8b42a9b438b510c/html5/thumbnails/27.jpg)
User Story & Scenario Example
Scenario 3: Card has been disabled
Given the card is disabled
When the customer requests cashThen the ATM should retain the card
And the ATM should say the card has been retained
![Page 28: Hello bdd](https://reader035.vdocument.in/reader035/viewer/2022070318/55782f95d8b42a9b438b510c/html5/thumbnails/28.jpg)
Tools
• Python 0 Should-DSL0 Lettuce0 Pycuke
• Java0 Jbehave0 Concordion
• Ruby0 Cucumber
• Others0 Fitnesse0 Tartare
![Page 29: Hello bdd](https://reader035.vdocument.in/reader035/viewer/2022070318/55782f95d8b42a9b438b510c/html5/thumbnails/29.jpg)
BDD life cycle
![Page 30: Hello bdd](https://reader035.vdocument.in/reader035/viewer/2022070318/55782f95d8b42a9b438b510c/html5/thumbnails/30.jpg)
BDD Life cycle
• Let’s choose a problem Given a number, what is its factorial?• User Story:
0 Feature: Compute factorial 0 In order to learn BDD0As beginners 0We'll implement factorial
![Page 31: Hello bdd](https://reader035.vdocument.in/reader035/viewer/2022070318/55782f95d8b42a9b438b510c/html5/thumbnails/31.jpg)
BDD Life cycle
•Writte the first scenario:• Scenario: Factorial of 0
0Given I have the number 0 0When I compute its factorial 0Then I see the number 1
![Page 32: Hello bdd](https://reader035.vdocument.in/reader035/viewer/2022070318/55782f95d8b42a9b438b510c/html5/thumbnails/32.jpg)
BDD Life cycleDefine steps in python (or another language):
![Page 33: Hello bdd](https://reader035.vdocument.in/reader035/viewer/2022070318/55782f95d8b42a9b438b510c/html5/thumbnails/33.jpg)
BDD Life cycle
Run and watch it fail
![Page 34: Hello bdd](https://reader035.vdocument.in/reader035/viewer/2022070318/55782f95d8b42a9b438b510c/html5/thumbnails/34.jpg)
BDD Life cycle Write code to make it pass:
![Page 35: Hello bdd](https://reader035.vdocument.in/reader035/viewer/2022070318/55782f95d8b42a9b438b510c/html5/thumbnails/35.jpg)
BDD Life cycle
Run again and watch it pass:
![Page 36: Hello bdd](https://reader035.vdocument.in/reader035/viewer/2022070318/55782f95d8b42a9b438b510c/html5/thumbnails/36.jpg)
BDD Life cycle
Add the another scenarios:0 Scenario: Factorial of 1
0Given I have the number 1 0When I compute its factorial 0Then I see the number 1
0 Scenario: Factorial of 2 0Given I have the number 2 0When I compute its factorial 0Then I see the number 2
![Page 37: Hello bdd](https://reader035.vdocument.in/reader035/viewer/2022070318/55782f95d8b42a9b438b510c/html5/thumbnails/37.jpg)
BDD Life cycle0We don’t need change the steps in python because we haven’t changed the definition
![Page 38: Hello bdd](https://reader035.vdocument.in/reader035/viewer/2022070318/55782f95d8b42a9b438b510c/html5/thumbnails/38.jpg)
BDD Life cycleWrite code to make it pass:
![Page 39: Hello bdd](https://reader035.vdocument.in/reader035/viewer/2022070318/55782f95d8b42a9b438b510c/html5/thumbnails/39.jpg)
BDD Life cycle
Execute!
![Page 40: Hello bdd](https://reader035.vdocument.in/reader035/viewer/2022070318/55782f95d8b42a9b438b510c/html5/thumbnails/40.jpg)
BDD Life cycle
• We can add more scenarios and improve the software quality:0 What happen when we introduce a character?0 What happen when we introduce a float?0 What happen when we not introduce nothing?0 …
![Page 41: Hello bdd](https://reader035.vdocument.in/reader035/viewer/2022070318/55782f95d8b42a9b438b510c/html5/thumbnails/41.jpg)
BDD Life cycleRefactor your scenarios and source code:
![Page 42: Hello bdd](https://reader035.vdocument.in/reader035/viewer/2022070318/55782f95d8b42a9b438b510c/html5/thumbnails/42.jpg)
BDD Life cycle
First:0 Analyze the feature
•Google API about geography codification:0 We want offer a product to improve the geography
knowledge0 As a user we need a product that when a city is
introduced the application returns the country.
![Page 43: Hello bdd](https://reader035.vdocument.in/reader035/viewer/2022070318/55782f95d8b42a9b438b510c/html5/thumbnails/43.jpg)
BDD Life cycle
0User story:0 As a user0 I want know the country code of one city0 In order to improve my geography knowledge
![Page 44: Hello bdd](https://reader035.vdocument.in/reader035/viewer/2022070318/55782f95d8b42a9b438b510c/html5/thumbnails/44.jpg)
BDD Life cycle
• We start thinking about the possible scenarios to build the acceptance criteria:0 What happen if the city not exists?0 What happen if the city parameter is null?0 What happen if the city is mispelled 0 Should the request be authenticated?
![Page 45: Hello bdd](https://reader035.vdocument.in/reader035/viewer/2022070318/55782f95d8b42a9b438b510c/html5/thumbnails/45.jpg)
BDD life cycle
Scenario Outline: Retrieve the geolocation with city name given Given a <city> name When I request the geoencoding of the city Then I obtain the <city> name with the <country_code>
Examples: | city | country_code | | Barcelona | ES | | Paris | FR | | San+Francisco | US |
![Page 46: Hello bdd](https://reader035.vdocument.in/reader035/viewer/2022070318/55782f95d8b42a9b438b510c/html5/thumbnails/46.jpg)
BDD life cycle
• Code the scenario!• Every line in the scenario is a function or
method in the code.0 Given: Preconditions settings0 When: API request 0 Then: Assertions
![Page 47: Hello bdd](https://reader035.vdocument.in/reader035/viewer/2022070318/55782f95d8b42a9b438b510c/html5/thumbnails/47.jpg)
BDD life cycle
• Execute:
![Page 48: Hello bdd](https://reader035.vdocument.in/reader035/viewer/2022070318/55782f95d8b42a9b438b510c/html5/thumbnails/48.jpg)
BDD life cycle
• Build the source code
• Remember build only the source code required to pass the scenario
• If something is not required, delete it
![Page 49: Hello bdd](https://reader035.vdocument.in/reader035/viewer/2022070318/55782f95d8b42a9b438b510c/html5/thumbnails/49.jpg)
BDD life cycle
Execute:
![Page 50: Hello bdd](https://reader035.vdocument.in/reader035/viewer/2022070318/55782f95d8b42a9b438b510c/html5/thumbnails/50.jpg)
BDD life cycle
Refactor:0 Give feedback to the stakeholders and the whole team0 Refactor the source code to improve it!0 Refactor the scenarios 0 Add new scenarios
![Page 51: Hello bdd](https://reader035.vdocument.in/reader035/viewer/2022070318/55782f95d8b42a9b438b510c/html5/thumbnails/51.jpg)
BDD life cycle
![Page 52: Hello bdd](https://reader035.vdocument.in/reader035/viewer/2022070318/55782f95d8b42a9b438b510c/html5/thumbnails/52.jpg)
BENEFITS
![Page 53: Hello bdd](https://reader035.vdocument.in/reader035/viewer/2022070318/55782f95d8b42a9b438b510c/html5/thumbnails/53.jpg)
Communication
Improve communication0 BDD is about conversations0 Ubiquitous language (shared between stakeholders and
whole team)0 Collaboration between stakeholders, Bussiness
Analysts, QA and programmers
Speak the same language = building toguether
![Page 54: Hello bdd](https://reader035.vdocument.in/reader035/viewer/2022070318/55782f95d8b42a9b438b510c/html5/thumbnails/54.jpg)
Documentation
• Formal documentation is not required• Scenarios can be used as a software
documentation• Every time the software changes… the
scenarios should be changed also (red, green, refactor)
Live Documentation!!!!
![Page 55: Hello bdd](https://reader035.vdocument.in/reader035/viewer/2022070318/55782f95d8b42a9b438b510c/html5/thumbnails/55.jpg)
Other benefits
• Only code the required functionality (YAGNI)
• Quick feedbackIf the tests are included in the CI
• Involve stakeholders in the implementation process
• Develop code right and right code• Give confidence in your code refactors
![Page 56: Hello bdd](https://reader035.vdocument.in/reader035/viewer/2022070318/55782f95d8b42a9b438b510c/html5/thumbnails/56.jpg)
Resources0 http://dannorth.net0 http://lizkeogh.com0 http://
www.slideshare.net/ajaydanait1/behavior-driven-development-bdd-16779998
0 http://behaviour-driven.org/0 http://cukes.info/0 http://lettuce.it/0 http://fitnesse.org/0 http://www.concordion.org/0 http://jbehave.org/0 User Stories Applied: For Agile Software Development, Mike Cohn0 Agile Testing: A Practical Guide for Testers and Agile Teams, Lisa
Crispin and Janet Gregory0 Specification by Example, Gojko Adzic
![Page 57: Hello bdd](https://reader035.vdocument.in/reader035/viewer/2022070318/55782f95d8b42a9b438b510c/html5/thumbnails/57.jpg)
Questions?
![Page 58: Hello bdd](https://reader035.vdocument.in/reader035/viewer/2022070318/55782f95d8b42a9b438b510c/html5/thumbnails/58.jpg)
Contact
Twiiter: @twiindan
Email: [email protected]
Linkedin: http://es.linkedin.com/in/antoniorobres
Web: www.softqatest.com