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

Web Acceptance Testing For Grumpy Programmers

Web Acceptance Testing For Grumpy Programmers

How you can bend Behat + Mink + PhantomJS to your will to create web acceptance tests

Chris Hartjes

May 15, 2013

More Decks by Chris Hartjes

Other Decks in Programming


  1. A New Test Type “BDD is a second-generation, outside–in, pull-based,

    multiple-stakeholder, multiple- scale, high-automation, agile methodology. It describes a cycle of interactions with well- defined outputs, resulting in the delivery of working, tested software that matters”
  2. A New Test Type Behavior-driven development specifies that tests of

    any unit of software should be specified in terms of the desired behavior of the unit.
  3. What’s The Scenario Given I am in a talk When

    the speaker is presenting And he glares at me I remain quiet
  4. How Do I Use It? 1. Install via Composer 2.

    Create a Feature with a Scenario 3. Run your test 4. Profit!
  5. Mink Framework for doing web acceptance testing Sits between Behat

    and browser emulator http://mink.behat.org
  6. How does it help? Provides a common API for browser

    interaction Provides built-in functionality for common tasks
  7. Why Selenium2? PhantomJS can pretend to be a standalone Selenium2

    server Configure Behat to send JavaScript scenarios to it
  8. CSS Selectors Best way to locate specific elements on a

    page If you disliked CSS before, this might push you over the edge
  9. Y U MAD CHRIS? 'html body div.container div.row div.span9 section#modals

    div#myModal.modal div.modal-header h3#myModalLabel' TOTALLY INTUITIVE Learn your browser debugger tools well
  10. Pro Tip #1 Give all your elements ID’s Make it

    easier for CSS selectors to find them
  11. Waiting For JavaScript Behat steps will need wait() commands for

    JS Gives time for browser to render Acceptance tests are not supposed to be fast
  12. Lessons Learned WAT is definitely “test-after” Learn CSS really well

    or else Twitter Rage ensues Good ratio is 90% unit - 10% WAT
  13. Advanced Level Use Behat Gearman extension to run scenarios in

    parallel http://extensions.behat.org/gearman/