Share
Embed
Transcript
72 slides
-
It is a tool to bring a structure into agile
processes. -
Requirements Analysis Design Develop Test [Royce 1970] 9 months 3
months 2 months 12 months ... -
StoryBDD could look like functional TDD to people from outside
BDD community, but it’s a lie. -
We are not testing that application functions as we (developers)
expect it to, but instead we’re testing that it fullfils clients business needs. -
Some applications could easily fullfill developers expectations and still not
being able to cover business needs. -
You might think about StoryBDD as a technique to teach
your clients about testing, but in reality it's a tool to teach you about client business. -
Feature: Authorization In order to get access to the shopping
history As a frequent buyer I need to be able to authenticate 1 2 3 possible scenarios scenario details -
Feature: Authorization In order to get access to the shopping
history As a frequent buyer I need to be able to authenticate Scenario: Successfully authenticating with correct credentials 1 2 3 scenario details -
Feature: Authorization In order to get access to the shopping
history As a frequent buyer I need to be able to authenticate Scenario: Successfully authenticating with correct credentials Given there is a user “everzet” with password “123” And I am on the login page When I fill in “username” with “everzet” And I fill in “password” with “123” And I press “login” Then I should see “Hello, everzet” 1 2 3 -
Feature: Authorization In order to get access to the shopping
history As a frequent buyer I need to be able to authenticate Scenario: Successfully authenticating with correct credentials Scenario: Can not authenticate with wrong credentials Scenario: Blocked user can not authenticate, even with correct credentials -
Feature: Authorization In order to get access to the shopping
history As a frequent buyer I need to be able to authenticate user story => -
StoryBDD helps ensuring that development team has understanding of business
on the same level that client does -
StoryBDD helps ensuring that development team has understanding of business
on the same level that client does And even leveling up client knowledge of his business -
” I want visitors to be able to register on
my website through simple registration form. Your hypothetical client -
in order to maintain my shopping history as a site
visitor i need to be able to register on this site -
in order to maintain my shopping history as a site
visitor i need to be able to register on this site Feature: registration -
in order to maintain my shopping history as a site
visitor i need to be able to register on this site Feature: registration benefit role (benefitiar) -
in order to maintain my shopping history as a site
visitor i need to be able to register on this site Feature: registration benefit role (benefitiar) in order to ... as a ... i need to ... Feature: ... benefit role (benefitiar) in order to ... as a ... i need to ... Feature: ... benefit role (benefitiar) in order to ... as a ... i need to ... Feature: ... benefit role (benefitiar) -
in order to ... as a ... i need to
... Feature: ... benefit role (benefitiar) in order to ... as a ... i need to ... Feature: ... benefit role (benefitiar) in order to ... as a ... i need to ... Feature: ... benefit role (benefitiar) in order to maintain my shopping history as a site visitor i need to be able to register on this site Feature: registration benefit role (benefitiar) SELECT f.* FROM ‘/features’ as f ORDER BY f.role, f.benefit LIMIT 10 PSEUDOAgileQL -
in order to maintain my shopping history as a site
visitor i need to be able to register on this site Feature: registration -
in order to maintain my shopping history as a site
visitor i need to be able to register on this site Feature: registration Scenario: Successful registration when visitor provides all the required info -
in order to maintain my shopping history as a site
visitor i need to be able to register on this site Feature: registration Scenario: Successful registration when visitor provides all the required info Scenario: Unable to register when visitor misses required info -
in order to maintain my shopping history as a site
visitor i need to be able to register on this site Feature: registration Scenario: Successful registration when visitor provides all the required info Scenario: Unable to register when visitor misses required info Scenario: ... -
in order to maintain my shopping history as a site
visitor i need to be able to register on this site Feature: registration Scenario: Successful registration when visitor provides all the required info Scenario: Unable to register when visitor misses required info Scenario: ... Scenario: ... Scenario: ... Scenario: ... Scenario: ... -
in order to maintain my shopping history as a site
visitor i need to be able to register on this site Feature: registration Scenario: Successful registration when visitor provides all the required info Given I am on homepage And I follow “sign up” When I fill in “email” with “[email protected]” And I fill in “username” with “linkedin” And I fill in “password” with “sha1_without_salt” And I press “register” Then I should see “You have been successfully registered” And I should be on homepage -
$> vim composer.json { “require-dev”: { “behat/behat”: “~2.4.5”, }, “config”:
{ “bin-dir”: “bin/” } } $> curl http://getcomposer.org/installer | php $> php composer.phar install --dev -
<?php use Behat\Behat\Context\ClosuredContextInterface, Behat\Behat\Context\TranslatedContextInterface, Behat\Behat\Context\BehatContext, Behat\Behat\Exception\PendingException; use Behat\Gherkin\Node\PyStringNode, Behat\Gherkin\Node\TableNode; class
FeatureContext extends BehatContext { public function __construct(array $parameters) { // Initialize your context here } } -
$> bin/behat ... You can implement step definitions for undefined
steps with these snippets: /** * @When /^I fill in “([^”]+)” with “([^”]+)”$/ */ public function iFillInWith($val1, $val2) { throw new PendingException(); } ... -
$> bin/behat ... You can implement step definitions for undefined
steps with these snippets: /** * @When /^I fill in “([^”]+)” with “([^”]+)”$/ */ public function iFillInWith($val1, $val2) { throw new PendingException(); } ... -
/** * @Given /^I am on homepage$/ */ public function
iAmOnHomepage() { throw new PendingException(); } /** * @Given /^I follow “sign up”$/ */ public function iFollowSignUp() { throw new PendingException(); } /** * @When /^I fill in “([^”]+)” with “([^”]+)”$/ */ public function iFillInWith($val1, $val2) { throw new PendingException(); } -
$> bin/behat Feature: registration in order to maintain my shopping
history as a site visitor i need to be able to register on this site Scenario: Successful registration when visitor provides all the required info Given I am on homepage TODO: write pending definition And I follow “sign up” When I fill in “email” with “[email protected]” And I fill in “username” with “linkedin” And I fill in “password” with “sha1_without_salt” And I press “register” Then I should see “You have been successfully registered” And I should be on homepage 1 scenario (1 pending) 8 steps (7 skipped, 1 pending) 0m0.015s -
/** * @Given /^I am on homepage$/ */ public function
iAmOnHomepage() { $crawler = new \Some\Crawler\Lib\Crawler(); $crawler->goto(“http://localhost:8080/”); if (200 !== $crawler->getCurrentStatusCode()) { throw new \RuntimeException(‘Can not open homepage’); } } -
$> bin/behat Feature: registration in order to maintain my shopping
history as a site visitor i need to be able to register on this site Scenario: Successful registration when visitor provides all the required info Given I am on homepage Can not open homepage And I follow “sign up” When I fill in “email” with “[email protected]” And I fill in “username” with “linkedin” And I fill in “password” with “sha1_without_salt” And I press “register” Then I should see “You have been successfully registered” And I should be on homepage 1 scenario (1 failed) 8 steps (7 skipped, 1 failed) 0m0.015s -
$> bin/behat Feature: registration in order to maintain my shopping
history as a site visitor i need to be able to register on this site Scenario: Successful registration when visitor provides all the required info Given I am on homepage And I follow “sign up” TODO: write pending definition When I fill in “email” with “[email protected]” And I fill in “username” with “linkedin” And I fill in “password” with “sha1_without_salt” And I press “register” Then I should see “You have been successfully registered” And I should be on homepage 1 scenario (1 pending) 8 steps (1 passed, 1 pending, 6 skipped) 0m0.015s