Download - BDD & Behat for PHPNE
![Page 1: BDD & Behat for PHPNE](https://reader034.vdocument.in/reader034/viewer/2022051521/5a65128a7f8b9aa2548b6a59/html5/thumbnails/1.jpg)
@Brunty
BEHAVIOUR DRIVEN DEVELOPMENT & BEHAT
TELLING STORIES THROUGH CODE
![Page 2: BDD & Behat for PHPNE](https://reader034.vdocument.in/reader034/viewer/2022051521/5a65128a7f8b9aa2548b6a59/html5/thumbnails/2.jpg)
@Brunty
Senior Software Engineer Viva IT
@Brunty @PHPem
![Page 3: BDD & Behat for PHPNE](https://reader034.vdocument.in/reader034/viewer/2022051521/5a65128a7f8b9aa2548b6a59/html5/thumbnails/3.jpg)
@Brunty
BEFORE WE TALK ABOUT BDD
![Page 4: BDD & Behat for PHPNE](https://reader034.vdocument.in/reader034/viewer/2022051521/5a65128a7f8b9aa2548b6a59/html5/thumbnails/4.jpg)
@Brunty
TDD VS BDD
![Page 5: BDD & Behat for PHPNE](https://reader034.vdocument.in/reader034/viewer/2022051521/5a65128a7f8b9aa2548b6a59/html5/thumbnails/5.jpg)
@Brunty
BDD IS TDD ‘DONE RIGHT’IT’S OFTEN SAID THAT…
![Page 6: BDD & Behat for PHPNE](https://reader034.vdocument.in/reader034/viewer/2022051521/5a65128a7f8b9aa2548b6a59/html5/thumbnails/6.jpg)
@Brunty
TDD IS BUILDING THE THING RIGHT
![Page 7: BDD & Behat for PHPNE](https://reader034.vdocument.in/reader034/viewer/2022051521/5a65128a7f8b9aa2548b6a59/html5/thumbnails/7.jpg)
@Brunty
BDD IS BUILDING THE RIGHT THING
![Page 8: BDD & Behat for PHPNE](https://reader034.vdocument.in/reader034/viewer/2022051521/5a65128a7f8b9aa2548b6a59/html5/thumbnails/8.jpg)
@Brunty
WE’LL BE LOOKING AT SCENARIO BDD
![Page 9: BDD & Behat for PHPNE](https://reader034.vdocument.in/reader034/viewer/2022051521/5a65128a7f8b9aa2548b6a59/html5/thumbnails/9.jpg)
@Brunty
BDD IS A SECOND-GENERATION, OUTSIDE-IN, PULL-BASED, MULTIPLE-STAKEHOLDER, MULTIPLE-SCALE, HIGH-AUTOMATION, AGILE METHODOLOGY.
DAN NORTH
http://dannorth.net/whats-in-a-story/
![Page 10: BDD & Behat for PHPNE](https://reader034.vdocument.in/reader034/viewer/2022051521/5a65128a7f8b9aa2548b6a59/html5/thumbnails/10.jpg)
@Brunty
SECOND-GENERATIONBREAK DOWN
![Page 11: BDD & Behat for PHPNE](https://reader034.vdocument.in/reader034/viewer/2022051521/5a65128a7f8b9aa2548b6a59/html5/thumbnails/11.jpg)
@Brunty
MULTIPLE-STAKEHOLDERBREAK DOWN
![Page 12: BDD & Behat for PHPNE](https://reader034.vdocument.in/reader034/viewer/2022051521/5a65128a7f8b9aa2548b6a59/html5/thumbnails/12.jpg)
@Brunty
AGILE METHODOLOGYBREAK DOWN
![Page 13: BDD & Behat for PHPNE](https://reader034.vdocument.in/reader034/viewer/2022051521/5a65128a7f8b9aa2548b6a59/html5/thumbnails/13.jpg)
@Brunty
MULTIPLE STAKEHOLDERS
![Page 14: BDD & Behat for PHPNE](https://reader034.vdocument.in/reader034/viewer/2022051521/5a65128a7f8b9aa2548b6a59/html5/thumbnails/14.jpg)
@Brunty
CONVERSATIONS ARE KEY
![Page 15: BDD & Behat for PHPNE](https://reader034.vdocument.in/reader034/viewer/2022051521/5a65128a7f8b9aa2548b6a59/html5/thumbnails/15.jpg)
@Brunty
HAVING CONVERSATIONS > CAPTURING
CONVERSATIONSAUTOMATING
CONVERSATIONS>
![Page 16: BDD & Behat for PHPNE](https://reader034.vdocument.in/reader034/viewer/2022051521/5a65128a7f8b9aa2548b6a59/html5/thumbnails/16.jpg)
@Brunty
HAVE CONVERSATIONS BEFORE YOU START WRITING CODE
![Page 17: BDD & Behat for PHPNE](https://reader034.vdocument.in/reader034/viewer/2022051521/5a65128a7f8b9aa2548b6a59/html5/thumbnails/17.jpg)
@Brunty
CAPTURE THE CONVERSATIONS SO YOU CAN USE THEM TO DRIVE DEVELOPMENT
![Page 18: BDD & Behat for PHPNE](https://reader034.vdocument.in/reader034/viewer/2022051521/5a65128a7f8b9aa2548b6a59/html5/thumbnails/18.jpg)
@Brunty
BDD IS THE ART OF USING EXAMPLES IN CONVERSATIONS TO ILLUSTRATE BEHAVIOUR
LIZ KEOGH
![Page 19: BDD & Behat for PHPNE](https://reader034.vdocument.in/reader034/viewer/2022051521/5a65128a7f8b9aa2548b6a59/html5/thumbnails/19.jpg)
@Brunty
EXAMPLES ARE ESSENTIAL
![Page 20: BDD & Behat for PHPNE](https://reader034.vdocument.in/reader034/viewer/2022051521/5a65128a7f8b9aa2548b6a59/html5/thumbnails/20.jpg)
@Bruntyhttps://github.com/cucumber/cucumber/wiki/Gherkin
GHERKIN DSL
![Page 21: BDD & Behat for PHPNE](https://reader034.vdocument.in/reader034/viewer/2022051521/5a65128a7f8b9aa2548b6a59/html5/thumbnails/21.jpg)
@Brunty
HUMAN READABLEGHERKIN IS…
![Page 22: BDD & Behat for PHPNE](https://reader034.vdocument.in/reader034/viewer/2022051521/5a65128a7f8b9aa2548b6a59/html5/thumbnails/22.jpg)
@Brunty
MULTI-LINGUAL SUPPORTTOOLS CAN INCLUDE…
![Page 23: BDD & Behat for PHPNE](https://reader034.vdocument.in/reader034/viewer/2022051521/5a65128a7f8b9aa2548b6a59/html5/thumbnails/23.jpg)
@Brunty
EN-PIRATEINCLUDING
https://github.com/Behat/Gherkin/blob/master/i18n.php#L313
![Page 24: BDD & Behat for PHPNE](https://reader034.vdocument.in/reader034/viewer/2022051521/5a65128a7f8b9aa2548b6a59/html5/thumbnails/24.jpg)
@Brunty
KEYWORD BASEDGHERKIN IS…
![Page 25: BDD & Behat for PHPNE](https://reader034.vdocument.in/reader034/viewer/2022051521/5a65128a7f8b9aa2548b6a59/html5/thumbnails/25.jpg)
@Brunty
LINE ORIENTEDGHERKIN IS…
![Page 26: BDD & Behat for PHPNE](https://reader034.vdocument.in/reader034/viewer/2022051521/5a65128a7f8b9aa2548b6a59/html5/thumbnails/26.jpg)
@Brunty
DOCUMENTATIONGHERKIN IS…
![Page 27: BDD & Behat for PHPNE](https://reader034.vdocument.in/reader034/viewer/2022051521/5a65128a7f8b9aa2548b6a59/html5/thumbnails/27.jpg)
@Brunty
AUTOMATIONGHERKIN ALLOWS…
![Page 28: BDD & Behat for PHPNE](https://reader034.vdocument.in/reader034/viewer/2022051521/5a65128a7f8b9aa2548b6a59/html5/thumbnails/28.jpg)
@Brunty
DEVELOPERS LOVE AUTOMATION
![Page 29: BDD & Behat for PHPNE](https://reader034.vdocument.in/reader034/viewer/2022051521/5a65128a7f8b9aa2548b6a59/html5/thumbnails/29.jpg)
@Brunty
FEATURES ARE STORIES
![Page 30: BDD & Behat for PHPNE](https://reader034.vdocument.in/reader034/viewer/2022051521/5a65128a7f8b9aa2548b6a59/html5/thumbnails/30.jpg)
WHEN WRITING STORIES
▸ Be descriptive
▸ Use real-world examples
▸ Describe the business logic
▸ Give context
![Page 31: BDD & Behat for PHPNE](https://reader034.vdocument.in/reader034/viewer/2022051521/5a65128a7f8b9aa2548b6a59/html5/thumbnails/31.jpg)
@Brunty
SINGLE FEATURE PER FILE
![Page 32: BDD & Behat for PHPNE](https://reader034.vdocument.in/reader034/viewer/2022051521/5a65128a7f8b9aa2548b6a59/html5/thumbnails/32.jpg)
@Brunty
Feature: As a [role] I want [feature] So that [benefit]
![Page 33: BDD & Behat for PHPNE](https://reader034.vdocument.in/reader034/viewer/2022051521/5a65128a7f8b9aa2548b6a59/html5/thumbnails/33.jpg)
@Brunty
Feature: In order to [achieve value] As a [role] I want [feature]
https://lizkeogh.com/2008/05/14/rip-as-a-i-want-so-that/
![Page 34: BDD & Behat for PHPNE](https://reader034.vdocument.in/reader034/viewer/2022051521/5a65128a7f8b9aa2548b6a59/html5/thumbnails/34.jpg)
@Brunty
SCENARIOS
![Page 35: BDD & Behat for PHPNE](https://reader034.vdocument.in/reader034/viewer/2022051521/5a65128a7f8b9aa2548b6a59/html5/thumbnails/35.jpg)
@Brunty
SCENARIOS ARE EXAMPLES
![Page 36: BDD & Behat for PHPNE](https://reader034.vdocument.in/reader034/viewer/2022051521/5a65128a7f8b9aa2548b6a59/html5/thumbnails/36.jpg)
@Brunty
EXAMPLES ARE ESSENTIAL
![Page 37: BDD & Behat for PHPNE](https://reader034.vdocument.in/reader034/viewer/2022051521/5a65128a7f8b9aa2548b6a59/html5/thumbnails/37.jpg)
@Brunty
MULTIPLE SCENARIOSFEATURES CAN HAVE
![Page 38: BDD & Behat for PHPNE](https://reader034.vdocument.in/reader034/viewer/2022051521/5a65128a7f8b9aa2548b6a59/html5/thumbnails/38.jpg)
@Brunty
MULTIPLE STEPSSCENARIOS HAVE…
![Page 39: BDD & Behat for PHPNE](https://reader034.vdocument.in/reader034/viewer/2022051521/5a65128a7f8b9aa2548b6a59/html5/thumbnails/39.jpg)
@Brunty
GIVENPUTS THE SYSTEM IN A KNOWN STATE
![Page 40: BDD & Behat for PHPNE](https://reader034.vdocument.in/reader034/viewer/2022051521/5a65128a7f8b9aa2548b6a59/html5/thumbnails/40.jpg)
@Brunty
WHENDESCRIBE A KEY ACTION
![Page 41: BDD & Behat for PHPNE](https://reader034.vdocument.in/reader034/viewer/2022051521/5a65128a7f8b9aa2548b6a59/html5/thumbnails/41.jpg)
@Brunty
THENDESCRIBE AN OBSERVABLE OUTCOME
![Page 42: BDD & Behat for PHPNE](https://reader034.vdocument.in/reader034/viewer/2022051521/5a65128a7f8b9aa2548b6a59/html5/thumbnails/42.jpg)
@Brunty
Given I have a “Large T-Shirt” product
When I add a “Large T-Shirt” to my basket
Then I should have a “Large T-Shirt” in my basket
![Page 43: BDD & Behat for PHPNE](https://reader034.vdocument.in/reader034/viewer/2022051521/5a65128a7f8b9aa2548b6a59/html5/thumbnails/43.jpg)
@Brunty
ANDTHERE’S ALSO…
![Page 44: BDD & Behat for PHPNE](https://reader034.vdocument.in/reader034/viewer/2022051521/5a65128a7f8b9aa2548b6a59/html5/thumbnails/44.jpg)
@Brunty
BUTTHERE’S ALSO…
![Page 45: BDD & Behat for PHPNE](https://reader034.vdocument.in/reader034/viewer/2022051521/5a65128a7f8b9aa2548b6a59/html5/thumbnails/45.jpg)
@Brunty
Given I have a “Large T-Shirt” product that costs £9.99
And I have an empty basket
And I am a tax-exempt customer
When I add a “Large T-Shirt” to my basket
Then I have a “Large T-Shirt” in my basket
And the basket total should be £9.99
But I do not have tax applied to my order
![Page 46: BDD & Behat for PHPNE](https://reader034.vdocument.in/reader034/viewer/2022051521/5a65128a7f8b9aa2548b6a59/html5/thumbnails/46.jpg)
@Brunty
STORY STRUCTURE: THE MAKEUP OF A FEATURE FILE
![Page 47: BDD & Behat for PHPNE](https://reader034.vdocument.in/reader034/viewer/2022051521/5a65128a7f8b9aa2548b6a59/html5/thumbnails/47.jpg)
@Brunty
Feature: As a customer
I want to be able to add products to my basket
So that I can have a gift for my partner
Scenario: I can add a product to the basket
Given I have a "Large T-Shirt" product
When I add a “Large T-Shirt” to my basket
Then I have a “Large T-Shirt” in my basket
FEATURE
![Page 48: BDD & Behat for PHPNE](https://reader034.vdocument.in/reader034/viewer/2022051521/5a65128a7f8b9aa2548b6a59/html5/thumbnails/48.jpg)
@Brunty
SCENARIO
Feature: As a customer
I want to be able to add products to my basket
So that I can have a gift for my partner
Scenario: I can add a product to the basket
Given I have a "Large T-Shirt" product
When I add a “Large T-Shirt” to my basket
Then I have a “Large T-Shirt” in my basket
![Page 49: BDD & Behat for PHPNE](https://reader034.vdocument.in/reader034/viewer/2022051521/5a65128a7f8b9aa2548b6a59/html5/thumbnails/49.jpg)
@Brunty
STEP
Feature: As a customer
I want to be able to add products to my basket
So that I can have a gift for my partner
Scenario: I can add a product to the basket
Given I have a "Large T-Shirt" product
When I add a “Large T-Shirt” to my basket
Then I have a “Large T-Shirt” in my basket
![Page 50: BDD & Behat for PHPNE](https://reader034.vdocument.in/reader034/viewer/2022051521/5a65128a7f8b9aa2548b6a59/html5/thumbnails/50.jpg)
@Brunty
WRITING A GOOD STORY
![Page 51: BDD & Behat for PHPNE](https://reader034.vdocument.in/reader034/viewer/2022051521/5a65128a7f8b9aa2548b6a59/html5/thumbnails/51.jpg)
@Brunty
Scenario: I can add a product to my basket
Given I am on the “/product/1” page
When I press “Add to basket”
Then I will see “Playstation 4”
And I will see £250
![Page 52: BDD & Behat for PHPNE](https://reader034.vdocument.in/reader034/viewer/2022051521/5a65128a7f8b9aa2548b6a59/html5/thumbnails/52.jpg)
@Brunty
Scenario: I can add a single product to my basket
Given I have a “Playstation 4” that costs £250
When I add the “Playstation 4” to my basket
Then I will have 1 product in my basket
And the basket total will be £250
BETTER STORY
![Page 53: BDD & Behat for PHPNE](https://reader034.vdocument.in/reader034/viewer/2022051521/5a65128a7f8b9aa2548b6a59/html5/thumbnails/53.jpg)
@Brunty
Scenario: I can add a product to my basket
Given I am on the “/product/1” page
When I press “Add to basket”
Then I will see “Playstation 4”
And I will see £250
WHAT HAPPENS WHEN THE UI CHANGES TO SAY “ADD TO CART”?
![Page 54: BDD & Behat for PHPNE](https://reader034.vdocument.in/reader034/viewer/2022051521/5a65128a7f8b9aa2548b6a59/html5/thumbnails/54.jpg)
@Brunty
DON’T WRITE IMPLEMENTATION IN FEATURES
![Page 55: BDD & Behat for PHPNE](https://reader034.vdocument.in/reader034/viewer/2022051521/5a65128a7f8b9aa2548b6a59/html5/thumbnails/55.jpg)
@Brunty
HOW DO DEVELOPERS WORK WITH IT?
![Page 56: BDD & Behat for PHPNE](https://reader034.vdocument.in/reader034/viewer/2022051521/5a65128a7f8b9aa2548b6a59/html5/thumbnails/56.jpg)
@Brunty
STEP DEFINITIONS
![Page 57: BDD & Behat for PHPNE](https://reader034.vdocument.in/reader034/viewer/2022051521/5a65128a7f8b9aa2548b6a59/html5/thumbnails/57.jpg)
@Brunty
Given I have a "Large T-Shirt" product
When I add a “Large T-Shirt” to my basket
Then I have a “Large T-Shirt” in my basket
![Page 58: BDD & Behat for PHPNE](https://reader034.vdocument.in/reader034/viewer/2022051521/5a65128a7f8b9aa2548b6a59/html5/thumbnails/58.jpg)
@Brunty
ARGUMENTS
![Page 59: BDD & Behat for PHPNE](https://reader034.vdocument.in/reader034/viewer/2022051521/5a65128a7f8b9aa2548b6a59/html5/thumbnails/59.jpg)
@Brunty
![Page 60: BDD & Behat for PHPNE](https://reader034.vdocument.in/reader034/viewer/2022051521/5a65128a7f8b9aa2548b6a59/html5/thumbnails/60.jpg)
@Brunty
SUITES & PROFILES
![Page 61: BDD & Behat for PHPNE](https://reader034.vdocument.in/reader034/viewer/2022051521/5a65128a7f8b9aa2548b6a59/html5/thumbnails/61.jpg)
@Brunty
TEST FEATURES WITH DIFFERENT CONFIGURATIONS
SUITES ALLOW YOU TO…
![Page 62: BDD & Behat for PHPNE](https://reader034.vdocument.in/reader034/viewer/2022051521/5a65128a7f8b9aa2548b6a59/html5/thumbnails/62.jpg)
@Brunty
SUITES CAN USE THE SAME FEATURE FILES. OR SUITES CAN USE DIFFERENT FEATURE FILES
FOR EXAMPLE:
![Page 63: BDD & Behat for PHPNE](https://reader034.vdocument.in/reader034/viewer/2022051521/5a65128a7f8b9aa2548b6a59/html5/thumbnails/63.jpg)
@Brunty
YOU CAN USE THE SAME FEATURE FILE TO TEST DIFFERENT IMPLEMENTATIONS
WITH SUITES AND TAGS…
![Page 64: BDD & Behat for PHPNE](https://reader034.vdocument.in/reader034/viewer/2022051521/5a65128a7f8b9aa2548b6a59/html5/thumbnails/64.jpg)
@Brunty
YOU CAN HAVE A UI SUITE THAT USES DIFFERENT STEP DEFINITIONS THAN A SERVICE / DOMAIN / LOWER LEVEL SUITE
FOR EXAMPLE:
![Page 65: BDD & Behat for PHPNE](https://reader034.vdocument.in/reader034/viewer/2022051521/5a65128a7f8b9aa2548b6a59/html5/thumbnails/65.jpg)
@Brunty
![Page 66: BDD & Behat for PHPNE](https://reader034.vdocument.in/reader034/viewer/2022051521/5a65128a7f8b9aa2548b6a59/html5/thumbnails/66.jpg)
@Brunty
![Page 67: BDD & Behat for PHPNE](https://reader034.vdocument.in/reader034/viewer/2022051521/5a65128a7f8b9aa2548b6a59/html5/thumbnails/67.jpg)
@Brunty
YOU CAN CHANGE IMPLEMENTATION WITHOUT CHANGING YOUR DOCUMENTED BUSINESS RULES
WITH SUITES AND TAGS…
![Page 68: BDD & Behat for PHPNE](https://reader034.vdocument.in/reader034/viewer/2022051521/5a65128a7f8b9aa2548b6a59/html5/thumbnails/68.jpg)
@Brunty
THIS IS WHERE THE POWER LIES
I FIND…
![Page 69: BDD & Behat for PHPNE](https://reader034.vdocument.in/reader034/viewer/2022051521/5a65128a7f8b9aa2548b6a59/html5/thumbnails/69.jpg)
@Brunty
IMPLEMENTATION CHANGES MORE FREQUENTLY THAN BUSINESS RULES
![Page 70: BDD & Behat for PHPNE](https://reader034.vdocument.in/reader034/viewer/2022051521/5a65128a7f8b9aa2548b6a59/html5/thumbnails/70.jpg)
@Brunty
DEMO TIME!
![Page 71: BDD & Behat for PHPNE](https://reader034.vdocument.in/reader034/viewer/2022051521/5a65128a7f8b9aa2548b6a59/html5/thumbnails/71.jpg)
@Brunty
IN SUMMARY
![Page 72: BDD & Behat for PHPNE](https://reader034.vdocument.in/reader034/viewer/2022051521/5a65128a7f8b9aa2548b6a59/html5/thumbnails/72.jpg)
@Brunty
CONVERSATIONS.
CONVERSATIONS.
CONVERSATIONS.
CONVERSATIONS.
CONVERSATIONS.
![Page 73: BDD & Behat for PHPNE](https://reader034.vdocument.in/reader034/viewer/2022051521/5a65128a7f8b9aa2548b6a59/html5/thumbnails/73.jpg)
@Brunty
STORIES TOLD BY REAL WORLD EXAMPLES.
USER STORIES AS REQUIREMENTS.
INVOLVE MULTIPLE STAKEHOLDERS.
WRITE FEATURES BEFORE CODE.
WRITE FEATURES WITHOUT IMPLEMENTATION.
![Page 74: BDD & Behat for PHPNE](https://reader034.vdocument.in/reader034/viewer/2022051521/5a65128a7f8b9aa2548b6a59/html5/thumbnails/74.jpg)
@Brunty
BEGINNING: HAVE A CONVERSATION, CAPTURE THAT CONVERSATION
MIDDLE: AUTOMATE AND IMPLEMENT THAT CONVERSATION
END: HAPPY STAKEHOLDERS AND WELL BUILT SOFTWARE
![Page 75: BDD & Behat for PHPNE](https://reader034.vdocument.in/reader034/viewer/2022051521/5a65128a7f8b9aa2548b6a59/html5/thumbnails/75.jpg)
@Brunty
LINKS & READINGhttps://cucumber.io/docs
https://adamcod.es/2014/05/15/test-doubles-mock-vs-stub.html
https://github.com/cucumber/cucumber/wiki/Gherkin
http://dannorth.net/whats-in-a-story/
http://dannorth.net/introducing-bdd/
http://lizkeogh.com/category/bdd/
http://lizkeogh.com/2014/01/22/using-bdd-with-legacy-systems/
http://inviqa.com/insights/bdd-guide
https://cucumber.io/blog/2015/03/24/single-source-of-truth
https://github.com/Behat/Gherkin/blob/master/i18n.php#L313
![Page 76: BDD & Behat for PHPNE](https://reader034.vdocument.in/reader034/viewer/2022051521/5a65128a7f8b9aa2548b6a59/html5/thumbnails/76.jpg)
@Brunty
THANKS FOR LISTENING