Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Presentation for Liverpool Behat UG opening

Presentation for Liverpool Behat UG opening

Konstantin Kudryashov

May 27, 2013
Tweet

More Decks by Konstantin Kudryashov

Other Decks in Technology

Transcript

  1. bdd

  2. BDD

  3. We are not testing that application functions as we (developers)

    expect it to, but instead we’re testing that it fullfils clients business needs.
  4. 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.
  5. 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
  6. 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
  7. 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
  8. 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
  9. Feature: Authorization In order to get access to the shopping

    history As a frequent buyer I need to be able to authenticate user story =>
  10. 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
  11. ” I want visitors to be able to register on

    my website through simple registration form. Your hypothetical client
  12. in order to maintain my shopping history as a site

    visitor i need to be able to register on this site
  13. in order to maintain my shopping history as a site

    visitor i need to be able to register on this site Feature: registration
  14. 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)
  15. 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)
  16. 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
  17. in order to maintain my shopping history as a site

    visitor i need to be able to register on this site Feature: registration
  18. 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
  19. 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
  20. 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: ...
  21. 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: ...
  22. 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
  23. $> 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
  24. $> 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(); } ...
  25. $> 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(); } ...
  26. /** * @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(); }
  27. $> 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
  28. /** * @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’); } }
  29. $> 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
  30. $> 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