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

Automated Acceptance Testing: Behavior Driven Development and PHP

Automated Acceptance Testing: Behavior Driven Development and PHP

In this presentation we introduce BDD and discuss communication, test writing, and test automation with Behat.

Jason Fox

July 10, 2013
Tweet

More Decks by Jason Fox

Other Decks in Programming

Transcript

  1. Scenario: User can log in Given I am on “/login”

    And I fill “username” with “jfox” And I fill “password” with “$3cr3t” When I press “Login” Then I should be on “/home” DescribingK
  2. You can implement step definitions for undefined steps with these

    snippets: /** * @Given /^I do "([^"]*)" things$/ */ public function iDoThings($arg1) { throw new PendingException(); } TestingN
  3. TestingN /** * Fills in form field with specified id|name|label|value.

    * * @When /^(?:|I )fill in "(?P<field>(?:[^"]|\\")*)" with "(? P<value>(?:[^"]|\\")*)"$/ */ public function fillField($field, $value) { $field = $this->fixStepArgument($field); $value = $this->fixStepArgument($value); $this->getSession()->getPage()->fillField($field, $value); }
  4. Scenario: User can pick an avatar Given I am on

    “/login” And I fill “username” with “jfox” And I fill “password” with “$3cr3t” And I press “Login” And I go to “/profile” And I click on “Avatars” And I click on “Cool Dude” When I click “Save” Then I should see “Avatar: Cool Dude” Anti-patterns 9
  5. Scenario: User can pick an avatar Given I access “/profile/avatars”

    And I click on “Cool Dude” When I click “Save” Then I should see “Avatar: Cool Dude” Anti-patterns 9
  6. Scenario: Successful API user request Given I have a valid

    OAuth access token And and my request route is “/api/user/12” When I issue a “GET” request Then my response should be “200” And my response body should contain “jfox” Anti-patterns 9
  7. Scenario: Successful API user request Given I have authenticated When

    I request “/api/user/12” Then my response should contain “jfox” Anti-patterns 9