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

Zip-BDD-doo-dah

 Zip-BDD-doo-dah

BDD, Drupal and Behat. Andrew Larcombe and Graham Taylor, Drupalcamp London March 2013

Andrew Larcombe

March 03, 2013
Tweet

More Decks by Andrew Larcombe

Other Decks in Programming

Transcript

  1. What Problem Are We Trying to Solve? Language Assumption that

    when something is stated everyone understands Sunday, 3 March 13
  2. What Problem Are We Trying to Solve? Language Assumption that

    when something is stated everyone understands Consquences: Late, delayed products Sunday, 3 March 13
  3. Why not (just) Test-Driven Development? Traditional TDD - ‘Unit’ Tests

    Inside Out “Refactoring Problem” - Change code, maintain behaviour “Accessibility Problem” - Who can read it? Sunday, 3 March 13
  4. Test-Driven Development tests written first repeatable, automated Domain Driven Design

    describes the business domain gives us a common (ubiquitous) language BDD Sunday, 3 March 13
  5. Test-Driven Development tests written first repeatable, automated Domain Driven Design

    describes the business domain gives us a common (ubiquitous) language Support Gherkin, Behat Jenkins, JIRA, Sauce, others BDD Sunday, 3 March 13
  6. The conversation... Different approaches to solving problems Variety of experiences

    Understanding of jargon, motivations Sunday, 3 March 13
  7. Given some context When do something Then I expect something

    to happen to add business value The scenario... Sunday, 3 March 13
  8. Given I am on the gateway page When I login

    as Fred Smith Then I expect to be on Fred Smith’s user account page The scenario... Sunday, 3 March 13
  9. Given I am on the gateway page When I login

    as Fred Smith Then I expect to be on Fred Smith’s user account page But wait... It’s a specification... It’s documentation... It’s an automated test... Sunday, 3 March 13
  10. Setup Drupal BDD = Behat / Mink / Gherkin +

    3rd Party Integration + Automation Sunday, 3 March 13
  11. { "require": { "behat/behat": "2.4.*@stable", "behat/mink": "1.4@stable", "behat/mink-goutte-driver": "*", "behat/mink-selenium-driver":

    "*", "behat/mink-selenium2-driver": "*", "behat/mink-sahi-driver": "*", "behat/mink-zombie-driver": "*", "drupal/drupal-extension": "*", "symfony/process": "*", "behat/symfony2-extension": "*", "symfony/form": "*", "symfony/validator": "*", "behat/mink-extension": "*", "symfony/http-kernel": "*", "fabpot/goutte": "dev-master#5f7fd00", "sauce/connect": "*", "sauce/sausage": "*", "vipsoft/jira-extension": "*" }, "minimum-stability": "dev", "config": { "bin-dir": "bin/" } } Composer.json https://packagist.org/ Sunday, 3 March 13
  12. $ curl http://getcomposer.org/installer | php $ php composer.phar install $

    bin/behat --init Installation Sunday, 3 March 13
  13. Behat.yml # Behat.yml default: paths: features: 'features' bootstrap: 'features/bootstrap' context:

    parameters: drupal_users: admin user: username: 'admin' password: 'admin' default_browser: 'goutte' extensions: Behat\MinkExtension\Extension: goutte: ~ selenium2: ~ base_url: 'http://londonkickstart.local' javascript_session: 'selenium2' Drupal\DrupalExtension\Extension: blackbox: ~ drush: alias: 'kickstart' Sunday, 3 March 13
  14. @todrink @cart Feature: Add drinking item to cart In order

    to buy something to drink with As any user I should be able to add a coffee mug to my cart Scenario: View the drinking options text and links on the page Given I am on the homepage When I click "To drink with" Then I should see the heading "Coffee Mugs" And I should see the link "Drupal Commerce to Wake You Up" Scenario: View coffee mug product information Given I am on the homepage When I click "To drink with" And I click "Drupal Commerce to Wake You Up" Then I should see the following <texts> | texts | | Drupal Commerce to Wake You Up | | Acme gear | | $8.00 | | Product Description | | SKU: MG1-BLU-OS | ... todrink.feature Sunday, 3 March 13
  15. # sauce.yml default: extensions: Behat\MinkExtension\Extension: wd_host: SAUCE_USERNAME:API_KEY:@ondemand.saucelabs.com/wd/hub default_session: 'selenium2' iPad:

    extensions: Behat\MinkExtension\Extension: selenium2: browser: iPad capabilities: { platform: Mac 10.8, version: 6} https://saucelabs.com/docs/browsers Sauce connect = https://saucelabs.com/docs/connect Sunday, 3 March 13
  16. Image Credits: http://knowyourmeme.com/photos/275025-wat http://www.flickr.com/photos/mgifford/7396924736/ http://www.businessinfest.info/wp-content/uploads/2012/08/business-analyst.jpg http://www.flickr.com/photos/ceardach/4550836301/ Thank You! We are

    Graham Taylor @g_taylor Andrew Larcombe @andrewl Links Dan North: http://dannorth.net/blog Liz Keogh: http://lizkeogh.com Gojko Adzic: http://gojko.net http://specificationbyexample.com Behat - http://behat.org Mink - http://mink.behat.org http://drupal.org/project/doobie Sunday, 3 March 13