bdd with behat and phpspec
TRANSCRIPT
BDD with Behat and PHPSpecRob Ingram
Image credit: J Williams
Outline
Narrative
Background
Scenarios
Outline
In order to <achieve a business goal>
As a <stakeholder>
I want <something>
Outline
Feature: store locator
In order to shop at the closest store
As a customer
I want to search for stores in my city
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
Scenario
Given <a context>
When <something happens>
Then <I expect some outcomes>
ScenarioScenario: 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”
ScenarioScenario: 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 |
Background
Background:
Given I am logged in
Image credit: PittCaleb
PHPSpec<?php
namespace spec;
use PhpSpec\ObjectBehavior;
class MarkdownSpec extends ObjectBehavior{ function it_converts_plain_text_to_html_paragraphs() { $this->toHtml("Hi, there")->shouldReturn("<p>Hi, there</p>"); }}
Live coding
Kinda
Image credit: @joefoodie
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/