Successfully reported this slideshow.
Your SlideShare is downloading. ×

BDD & Behat for PHPUK

Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Upcoming SlideShare
BDD & Behat for PHPNE
BDD & Behat for PHPNE
Loading in …3
×

Check these out next

1 of 80 Ad

BDD & Behat for PHPUK

Download to read offline

Stories? Scenarios? BDD? Are these just more words in the ever-growing list of jargon that developers have to know? Or are they something more important than new terms to memorise? In this session we'll look at how BDD fits into the software development work-flow, how to tell user stories through features, and how to automate them in Behat. These techniques will help to ensure you're writing well designed and tested software that focuses on what the users want from a system.

Stories? Scenarios? BDD? Are these just more words in the ever-growing list of jargon that developers have to know? Or are they something more important than new terms to memorise? In this session we'll look at how BDD fits into the software development work-flow, how to tell user stories through features, and how to automate them in Behat. These techniques will help to ensure you're writing well designed and tested software that focuses on what the users want from a system.

Advertisement
Advertisement

More Related Content

Similar to BDD & Behat for PHPUK (20)

Advertisement

Recently uploaded (20)

BDD & Behat for PHPUK

  1. 1. @Brunty BEHAVIOUR DRIVEN DEVELOPMENT & BEHAT TELLING STORIES THROUGH CODE
  2. 2. @Brunty Senior Software Engineer Viva IT @Brunty @PHPem
  3. 3. @Brunty TDD VS BDD
  4. 4. @Brunty BDD IS TDD ‘DONE RIGHT’ IT’S OFTEN SAID THAT…
  5. 5. @Brunty TDD ALONGSIDE BDD TDD VS BDD
  6. 6. @Brunty TDD IS BUILDING THE THING RIGHT
  7. 7. @Brunty BDD IS BUILDING THE RIGHT THING
  8. 8. @Brunty WE’LL BE LOOKING AT SCENARIO BDD
  9. 9. @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/
  10. 10. @Brunty SECOND-GENERATION BREAK DOWN
  11. 11. @Brunty MULTIPLE-STAKEHOLDER BREAK DOWN
  12. 12. @Brunty AGILE METHODOLOGY BREAK DOWN
  13. 13. @Brunty MULTIPLE STAKEHOLDERS
  14. 14. @Brunty Technical
 people Domain
 experts Users
 of the system !
  15. 15. @Brunty What the
 technical
 people think
 they want What the
 business
 thinks they
 want What the
 users of the
 system think
 they want !
  16. 16. @Brunty CONVERSATIONS ARE KEY
  17. 17. @Brunty HAVING CONVERSATIONS > CAPTURING CONVERSATIONS AUTOMATING CONVERSATIONS >
  18. 18. @Brunty HAVE CONVERSATIONS BEFORE YOU START WRITING CODE
  19. 19. @Brunty CAPTURE THE CONVERSATIONS SO YOU CAN USE THEM TO DRIVE DEVELOPMENT
  20. 20. @Brunty BDD IS THE ART OF USING EXAMPLES IN CONVERSATIONS TO ILLUSTRATE BEHAVIOUR LIZ KEOGH
  21. 21. @Brunty EXAMPLES ARE ESSENTIAL
  22. 22. @Bruntyhttps://github.com/cucumber/cucumber/wiki/Gherkin GHERKIN DSL
  23. 23. @Brunty HUMAN READABLE GHERKIN IS…
  24. 24. @Brunty MULTI-LINGUAL SUPPORT TOOLS CAN INCLUDE…
  25. 25. @Brunty EN-PIRATE INCLUDING https://github.com/Behat/Gherkin/blob/master/i18n.php#L313
  26. 26. @Brunty KEYWORD BASED GHERKIN IS…
  27. 27. @Brunty LINE ORIENTED GHERKIN IS…
  28. 28. @Brunty DOCUMENTATION GHERKIN IS…
  29. 29. @Brunty AUTOMATION GHERKIN ALLOWS…
  30. 30. @Brunty DEVELOPERS LOVE AUTOMATION
  31. 31. @Brunty JUST BECAUSE YOU’RE WRITING GHERKIN, DOESN’T MEAN YOU’RE DOING BDD
  32. 32. @Brunty FEATURES ARE STORIES
  33. 33. WHEN WRITING STORIES ▸ Be descriptive ▸ Use real-world examples ▸ Describe the business logic ▸ Give context
  34. 34. @Brunty SINGLE FEATURE PER FILE
  35. 35. @Brunty Feature: As a [role] I want [feature] So that [benefit]
  36. 36. @Bruntyhttps://lizkeogh.com/2008/05/14/rip-as-a-i-want-so-that/ Feature: In order to [achieve value] As a [role] I want [feature]
  37. 37. @Brunty SCENARIOS
  38. 38. @Brunty SCENARIOS ARE EXAMPLES
  39. 39. @Brunty EXAMPLES ARE ESSENTIAL
  40. 40. @Brunty MULTIPLE SCENARIOS FEATURES CAN HAVE
  41. 41. @Brunty MULTIPLE STEPS SCENARIOS HAVE…
  42. 42. @Brunty GIVEN PUTS THE SYSTEM IN A KNOWN STATE
  43. 43. @Brunty WHEN DESCRIBE A KEY ACTION
  44. 44. @Brunty THEN DESCRIBE AN OBSERVABLE OUTCOME
  45. 45. @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
  46. 46. @Brunty AND THERE’S ALSO…
  47. 47. @Brunty BUT THERE’S ALSO…
  48. 48. @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
  49. 49. @Brunty STORY STRUCTURE: THE MAKEUP OF A FEATURE FILE
  50. 50. @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
  51. 51. @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
  52. 52. @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
  53. 53. @Brunty WRITING A GOOD STORY
  54. 54. @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
  55. 55. @Brunty Scenario: I can add aproduct 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
  56. 56. @Brunty WHAT HAPPENS WHEN THE UI CHANGES TO SAY “ADD TO CART”? 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
  57. 57. @Brunty DON’T WRITE IMPLEMENTATION IN FEATURES
  58. 58. @Brunty HOW DO DEVELOPERS WORK WITH IT?
  59. 59. @Brunty STEP DEFINITIONS
  60. 60. @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
  61. 61. @Brunty ARGUMENTS
  62. 62. @Brunty
  63. 63. @Brunty SUITES & PROFILES
  64. 64. @Brunty TEST FEATURES WITH DIFFERENT CONFIGURATIONS SUITES ALLOW YOU TO…
  65. 65. @Brunty SUITES CAN USE THE SAME FEATURE FILES. OR SUITES CAN USE DIFFERENT FEATURE FILES FOR EXAMPLE:
  66. 66. @Brunty YOU CAN USE THE SAME FEATURE FILE TO TEST DIFFERENT IMPLEMENTATIONS WITH SUITES AND TAGS…
  67. 67. @Brunty YOU CAN HAVE A UI SUITE THAT USES DIFFERENT STEP DEFINITIONS THAN A SERVICE / DOMAIN / LOWER LEVEL SUITE FOR EXAMPLE:
  68. 68. @Brunty
  69. 69. @Brunty
  70. 70. @Brunty YOU CAN CHANGE IMPLEMENTATION WITHOUT CHANGING YOUR DOCUMENTED BUSINESS RULES WITH SUITES AND TAGS…
  71. 71. @Brunty THIS IS WHERE THE POWER LIES I FIND…
  72. 72. @Brunty IMPLEMENTATION CHANGES MORE FREQUENTLY THAN BUSINESS RULES
  73. 73. @Brunty DEMO TIME!
  74. 74. @Brunty IN SUMMARY
  75. 75. @Brunty COLLABORATION THROUGH CONVERSATION WITH CONCRETE EXAMPLES
  76. 76. @Brunty STORIES TOLD BY REAL WORLD EXAMPLES. USER STORIES AS REQUIREMENTS. INVOLVE MULTIPLE STAKEHOLDERS. WRITE FEATURES BEFORE CODE. WRITE FEATURES WITHOUT IMPLEMENTATION.
  77. 77. @Brunty BEGINNING: HAVE A CONVERSATION, CAPTURE THAT CONVERSATION MIDDLE: AUTOMATE AND IMPLEMENT THAT CONVERSATION END: HAPPY STAKEHOLDERS AND WELL BUILT SOFTWARE
  78. 78. @Brunty LINKS & READING https://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
  79. 79. @Brunty THANKS FOR LISTENING
  80. 80. @Brunty http://joind.in/talk/e212b @Brunty @PHPem matt@mfyu.co.uk

×