development (bdd) behavior driven · cucumber bdd framework feature files translation into code...
TRANSCRIPT
![Page 1: Development (BDD) Behavior Driven · Cucumber BDD framework Feature files Translation into code Cucumber Test scripts Test runner (JUnit) SUT. Cucumber: Gherkin logic Feature: Withdraw](https://reader033.vdocuments.mx/reader033/viewer/2022051606/601e8e6369aa906f3f33994f/html5/thumbnails/1.jpg)
Behavior Driven Development (BDD)
Pavel Rabetski
![Page 2: Development (BDD) Behavior Driven · Cucumber BDD framework Feature files Translation into code Cucumber Test scripts Test runner (JUnit) SUT. Cucumber: Gherkin logic Feature: Withdraw](https://reader033.vdocuments.mx/reader033/viewer/2022051606/601e8e6369aa906f3f33994f/html5/thumbnails/2.jpg)
Volvo Group Telematics
![Page 3: Development (BDD) Behavior Driven · Cucumber BDD framework Feature files Translation into code Cucumber Test scripts Test runner (JUnit) SUT. Cucumber: Gherkin logic Feature: Withdraw](https://reader033.vdocuments.mx/reader033/viewer/2022051606/601e8e6369aa906f3f33994f/html5/thumbnails/3.jpg)
Agenda
● Introduction to BDD● Cucumber BDD framework● Live demo● Pros/cons of BDD● Questions?
![Page 4: Development (BDD) Behavior Driven · Cucumber BDD framework Feature files Translation into code Cucumber Test scripts Test runner (JUnit) SUT. Cucumber: Gherkin logic Feature: Withdraw](https://reader033.vdocuments.mx/reader033/viewer/2022051606/601e8e6369aa906f3f33994f/html5/thumbnails/4.jpg)
Introduction to BDD
![Page 5: Development (BDD) Behavior Driven · Cucumber BDD framework Feature files Translation into code Cucumber Test scripts Test runner (JUnit) SUT. Cucumber: Gherkin logic Feature: Withdraw](https://reader033.vdocuments.mx/reader033/viewer/2022051606/601e8e6369aa906f3f33994f/html5/thumbnails/5.jpg)
Introduction to BDD
Test Driven Development
Dan North
![Page 6: Development (BDD) Behavior Driven · Cucumber BDD framework Feature files Translation into code Cucumber Test scripts Test runner (JUnit) SUT. Cucumber: Gherkin logic Feature: Withdraw](https://reader033.vdocuments.mx/reader033/viewer/2022051606/601e8e6369aa906f3f33994f/html5/thumbnails/6.jpg)
Introduction to BDD
![Page 7: Development (BDD) Behavior Driven · Cucumber BDD framework Feature files Translation into code Cucumber Test scripts Test runner (JUnit) SUT. Cucumber: Gherkin logic Feature: Withdraw](https://reader033.vdocuments.mx/reader033/viewer/2022051606/601e8e6369aa906f3f33994f/html5/thumbnails/7.jpg)
Introduction to BDD
MoneyWithdraw- success when enough money on account- fails when lack of money on account
agiledox >
![Page 8: Development (BDD) Behavior Driven · Cucumber BDD framework Feature files Translation into code Cucumber Test scripts Test runner (JUnit) SUT. Cucumber: Gherkin logic Feature: Withdraw](https://reader033.vdocuments.mx/reader033/viewer/2022051606/601e8e6369aa906f3f33994f/html5/thumbnails/8.jpg)
Introduction to BDD
Test Driven DevelopmentBehavior
![Page 9: Development (BDD) Behavior Driven · Cucumber BDD framework Feature files Translation into code Cucumber Test scripts Test runner (JUnit) SUT. Cucumber: Gherkin logic Feature: Withdraw](https://reader033.vdocuments.mx/reader033/viewer/2022051606/601e8e6369aa906f3f33994f/html5/thumbnails/9.jpg)
Introduction to BDD
I want ... function X(){ return Y;}
If I click this button then ...
Tester
DeveloperBA
![Page 10: Development (BDD) Behavior Driven · Cucumber BDD framework Feature files Translation into code Cucumber Test scripts Test runner (JUnit) SUT. Cucumber: Gherkin logic Feature: Withdraw](https://reader033.vdocuments.mx/reader033/viewer/2022051606/601e8e6369aa906f3f33994f/html5/thumbnails/10.jpg)
Introduction to BDD
![Page 11: Development (BDD) Behavior Driven · Cucumber BDD framework Feature files Translation into code Cucumber Test scripts Test runner (JUnit) SUT. Cucumber: Gherkin logic Feature: Withdraw](https://reader033.vdocuments.mx/reader033/viewer/2022051606/601e8e6369aa906f3f33994f/html5/thumbnails/11.jpg)
Ubiquitous requirements description
Documentation
Application code
Test scripts
Introduction to BDD
Tester
DeveloperBA
![Page 12: Development (BDD) Behavior Driven · Cucumber BDD framework Feature files Translation into code Cucumber Test scripts Test runner (JUnit) SUT. Cucumber: Gherkin logic Feature: Withdraw](https://reader033.vdocuments.mx/reader033/viewer/2022051606/601e8e6369aa906f3f33994f/html5/thumbnails/12.jpg)
Introduction to BDD
![Page 13: Development (BDD) Behavior Driven · Cucumber BDD framework Feature files Translation into code Cucumber Test scripts Test runner (JUnit) SUT. Cucumber: Gherkin logic Feature: Withdraw](https://reader033.vdocuments.mx/reader033/viewer/2022051606/601e8e6369aa906f3f33994f/html5/thumbnails/13.jpg)
Introduction to BDD
Behavior Driven Development(how we write and test code)(how we write and test requirements)
![Page 14: Development (BDD) Behavior Driven · Cucumber BDD framework Feature files Translation into code Cucumber Test scripts Test runner (JUnit) SUT. Cucumber: Gherkin logic Feature: Withdraw](https://reader033.vdocuments.mx/reader033/viewer/2022051606/601e8e6369aa906f3f33994f/html5/thumbnails/14.jpg)
Introduction to BDDStory (feature):
As a [role] I want [feature] so that [benefit]
Example: As a customer I want to withdraw money from an ATM so that I don’t have to go to the bank
![Page 15: Development (BDD) Behavior Driven · Cucumber BDD framework Feature files Translation into code Cucumber Test scripts Test runner (JUnit) SUT. Cucumber: Gherkin logic Feature: Withdraw](https://reader033.vdocuments.mx/reader033/viewer/2022051606/601e8e6369aa906f3f33994f/html5/thumbnails/15.jpg)
Introduction to BDDStory acceptance criteria (scenario):
Given [initial context] when [event] then [outcomes]
Example: Given there is enough money on my account when I make a withdrawal then I get the expected amount of money from the ATM
![Page 16: Development (BDD) Behavior Driven · Cucumber BDD framework Feature files Translation into code Cucumber Test scripts Test runner (JUnit) SUT. Cucumber: Gherkin logic Feature: Withdraw](https://reader033.vdocuments.mx/reader033/viewer/2022051606/601e8e6369aa906f3f33994f/html5/thumbnails/16.jpg)
Cucumber BDD framework
![Page 17: Development (BDD) Behavior Driven · Cucumber BDD framework Feature files Translation into code Cucumber Test scripts Test runner (JUnit) SUT. Cucumber: Gherkin logic Feature: Withdraw](https://reader033.vdocuments.mx/reader033/viewer/2022051606/601e8e6369aa906f3f33994f/html5/thumbnails/17.jpg)
Cucumber BDD framework
Feature files
Translation into code
Cucumber Test scripts
Test runner (JUnit)
SUT
![Page 18: Development (BDD) Behavior Driven · Cucumber BDD framework Feature files Translation into code Cucumber Test scripts Test runner (JUnit) SUT. Cucumber: Gherkin logic Feature: Withdraw](https://reader033.vdocuments.mx/reader033/viewer/2022051606/601e8e6369aa906f3f33994f/html5/thumbnails/18.jpg)
Cucumber: Gherkin logic
Feature: Withdraw money In order to avoid going to the bank As a customer I want to withdraw money from an ATM Scenario: Withdraw less money than the account has Given there is enough money on my account
When I make a withdrawal Then I get the expected amount of money from the ATMAnd receipt is printed
Gherkin logic
![Page 19: Development (BDD) Behavior Driven · Cucumber BDD framework Feature files Translation into code Cucumber Test scripts Test runner (JUnit) SUT. Cucumber: Gherkin logic Feature: Withdraw](https://reader033.vdocuments.mx/reader033/viewer/2022051606/601e8e6369aa906f3f33994f/html5/thumbnails/19.jpg)
Cucumber: parametrization
Scenario: Withdraw less money ... Given I have 200 SEK on my account
When I withdraw 100 SEK Then I get 100 SEK from the ATM
Scenario: Withdraw more money ... Given I have 50 SEK on my account
When I withdraw 100 SEK Then I get 0 SEK from the ATM
Gherkin logic Scenario: Withdraw money from the account Given I have <balance> SEK on my account
When I withdraw <withdraw> SEK Then I get <received> SEK from the ATM
Examples:
| balance| withdraw | received || 200 | 100 | 100 || 50 | 100 | 0 |
![Page 20: Development (BDD) Behavior Driven · Cucumber BDD framework Feature files Translation into code Cucumber Test scripts Test runner (JUnit) SUT. Cucumber: Gherkin logic Feature: Withdraw](https://reader033.vdocuments.mx/reader033/viewer/2022051606/601e8e6369aa906f3f33994f/html5/thumbnails/20.jpg)
Cucumber: annotations
@prod Scenario: Withdraw less money ... Given I have 200 SEK on my account
When I withdraw 100 SEK Then I get 100 SEK from the ATM
@test Scenario: Withdraw more money ... Given I have 50 SEK on my account
When I withdraw 100 SEK Then I get 0 SEK from the ATM
Gherkin logic
![Page 21: Development (BDD) Behavior Driven · Cucumber BDD framework Feature files Translation into code Cucumber Test scripts Test runner (JUnit) SUT. Cucumber: Gherkin logic Feature: Withdraw](https://reader033.vdocuments.mx/reader033/viewer/2022051606/601e8e6369aa906f3f33994f/html5/thumbnails/21.jpg)
BDD for complex systems
![Page 22: Development (BDD) Behavior Driven · Cucumber BDD framework Feature files Translation into code Cucumber Test scripts Test runner (JUnit) SUT. Cucumber: Gherkin logic Feature: Withdraw](https://reader033.vdocuments.mx/reader033/viewer/2022051606/601e8e6369aa906f3f33994f/html5/thumbnails/22.jpg)
Live demo: OEM portal
![Page 23: Development (BDD) Behavior Driven · Cucumber BDD framework Feature files Translation into code Cucumber Test scripts Test runner (JUnit) SUT. Cucumber: Gherkin logic Feature: Withdraw](https://reader033.vdocuments.mx/reader033/viewer/2022051606/601e8e6369aa906f3f33994f/html5/thumbnails/23.jpg)
Live demo: ATM
![Page 24: Development (BDD) Behavior Driven · Cucumber BDD framework Feature files Translation into code Cucumber Test scripts Test runner (JUnit) SUT. Cucumber: Gherkin logic Feature: Withdraw](https://reader033.vdocuments.mx/reader033/viewer/2022051606/601e8e6369aa906f3f33994f/html5/thumbnails/24.jpg)
Pros/cons of BDD
● Level of abstraction for steps?● Becomes complex for complex systems● Lack of tool support
![Page 25: Development (BDD) Behavior Driven · Cucumber BDD framework Feature files Translation into code Cucumber Test scripts Test runner (JUnit) SUT. Cucumber: Gherkin logic Feature: Withdraw](https://reader033.vdocuments.mx/reader033/viewer/2022051606/601e8e6369aa906f3f33994f/html5/thumbnails/25.jpg)
P.S. BDD in a context of FSMGiven I have 200 SEK on my account when I withdraw 100 SEK then I get 100 SEK from the ATM
![Page 26: Development (BDD) Behavior Driven · Cucumber BDD framework Feature files Translation into code Cucumber Test scripts Test runner (JUnit) SUT. Cucumber: Gherkin logic Feature: Withdraw](https://reader033.vdocuments.mx/reader033/viewer/2022051606/601e8e6369aa906f3f33994f/html5/thumbnails/26.jpg)
Questions?
![Page 27: Development (BDD) Behavior Driven · Cucumber BDD framework Feature files Translation into code Cucumber Test scripts Test runner (JUnit) SUT. Cucumber: Gherkin logic Feature: Withdraw](https://reader033.vdocuments.mx/reader033/viewer/2022051606/601e8e6369aa906f3f33994f/html5/thumbnails/27.jpg)
ReferencesCucumber framework:https://cucumber.io/Gherkin language:http://docs.behat.org/en/latest/guides/1.gherkin.html
Dan North about BDD:http://dannorth.net/introducing-bdd/How BDD can be misused:https://cucumber.io/blog/2014/03/03/the-worlds-most-misunderstood-collaboration-tool