Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

BDD with Behat and PHPSpec

260 views

Published on

A brief introduction to using Behat with PHP for Behaviour Driven Development

Published in: Internet
  • Be the first to comment

  • Be the first to like this

BDD with Behat and PHPSpec

  1. 1. BDD with Behat Rob Ingram
  2. 2. Image credit: J Williams
  3. 3. Outline Narrative Background Scenarios
  4. 4. Outline In order to <achieve a business goal> As a <stakeholder> I want <something>
  5. 5. Outline Feature: store locator In order to shop at the closest store As a customer I want to search for stores in my city
  6. 6. Alternative format Feature: store locator As a customer I want to search for stores in my city So that I can shop at the closest store
  7. 7. Scenario Given <a context> When <something happens> Then <I expect some outcomes>
  8. 8. Scenario Scenario: search by city name Given I am on the homepage When I fill in "location" with "Christchurch" And I press "Locate" Then I should be on the “Store Locator” page And I should see “Kathmandu Christchurch CBD Re:START” And I should see “0.2km”
  9. 9. Scenario Scenario: search by city name Given I am on the homepage When I fill in "location" with "Christchurch" And I press “Locate" Then I should be on the “Store Locator” page And I should see the following store results: | name | distance | | Kathmandu Christchurch CBD Re:START | 0.2km | | Kathmandu Tower Junction | 2.5km |
  10. 10. Background Background: Given I am logged in
  11. 11. Image credit: PittCaleb
  12. 12. PHPSpec <?php namespace spec; use PhpSpecObjectBehavior; class MarkdownSpec extends ObjectBehavior { function it_converts_plain_text_to_html_paragraphs() { $this->toHtml("Hi, there")->shouldReturn("<p>Hi, there</p>"); } }
  13. 13. Live coding Kinda
  14. 14. Image credit: @joefoodie
  15. 15. Links Behat: http://docs.behat.org/en/v3.0/ Behat Silverstripe: https://github.com/silverstripe- labs/silverstripe-behat-extension PHPSpec: http://www.phpspec.net/en/stable/

×