Behat - Arguably the best tool to switch to Automated testing from Manual Shweta Sharma
Behat: What and Why BDD PHP framework Cucumber Validates business use cases Verification versus Validation Gherkin Automated test cases Several extensions
Prerequisites Apache Mysql PHP Composer - System wide installation
Local Installation Create a directory List dependencies in composer.json composer install Configure behat.yml Initialize behat Verify your installation See list of predefined step definitions
composer.json
Structure of behat composer.json behat.yml Features directory Feature files Bootstrap FeatureContext file
behat.yml
Feature file Feature Background Scenario / Scenario Outline Given When Then And But
Mink extension What is it? Integration with Behat Ready to use Hides API differences between different browser emulators Controlling the Browser Traversing pages Traversal methods Mink selectors Manipulate the pages Interact with the pages Integration with Behat
Example Using Mink
Mink drivers Mink Drivers - http://mink.behat.org/en/latest/guides/drivers.html Goutte browserkit Selenium2 Zombie Sahi Selenium Execution Browser based Headless
Profiles Profiles Configure in behat.yml Multiple environments Multiple browsers Overrides settings of default profile
Example - Profiles
Tagged scenarios Run selective scenarios / Tags Exclude scenarios Configure in behat.yml Example: ~@wip Tagged scenarios Run via command line Example: smoke, feature-specific, language-specific
Example - Tagged scenarios Group by execution: bin\behat features --tags @smoke Single scenario: bin\behat features\demo.feature:13 (line number of of the scenario) Exclude scenarios: bin\behat features --tags ~@wip
Example
Custom step definitions Custom step definitions / functions FeatureContext.php
Extensions Drupal extension Symfony extension Screenshot extension Page Object extension Laravel extension Multiple API extensions Wordpress extension Reporting extensions
Demonstration Headless browser Using Chrome Tagged scenario Using a profile
Thank You Twitter - https://twitter.com/shwetasharma84 LinkedIn - https://www.linkedin.com/in/shweta-sharma-56a37b18/ Github - https://github.com/shwetaneelsharma Drupal.org - https://www.drupal.org/u/shwetaneelsharma Skype - shweta_ns Full day training at DrupalCon Nashville 2018 - https://events.drupal.org/nashville2018/training/automated-testing-using-behat-mink-and-drupal-extension Blogs - https://www.axelerant.com/resources/team-blog
Q & A Summary: Behat - http://docs.behat.org/en/v2.5/quick_intro.html Gherkin Mink extension Mink drivers Tagged scenarios Profile Custom step definitions Behat - http://docs.behat.org/en/v2.5/quick_intro.html Mink - http://mink.behat.org/en/latest/index.html