SapientGovernmentServices Put Your Behat On! 10/9/2015 A Better Way to Test for the Future
SapientGovernmentServices Put Your Behat On! Ali McIntosh ntosh
3 Background Run Behat Write Script Expand Behat Best Uses Objectives
4 Is an open source behavior-driven development framework Allows you to write “human-readable” tests Integrates perfectly with Drupal oject/drupalextension Behat is…
5 Describe exactly what you are testing in your own language Gherkin language Provides a usable and searchable list of scenarios/scenario structure Always start with following scenario keywords( given, when, then, and, but) “Human-Readable”?
6 A test is made up of a Feature – describe your goals for the test Scenario – layout the the path the test will follow Scenario outline – test multiple variables in the same test Cause and Effect
7 Every scenario we lay out will start with key words. These are the steps of our feature Given – known state When – key action Then - observe And, But – expand on state, action and observation Steps
8 Given /** * Moves user to the specified path. * /^I am in the "([^"]*)" path$/ * string $path */ public function iAmInThePath($path) { $this->moveToNewPath($path); } Statements in Code
9 Expand Functionality
10 Behat integrates with Selenium and other browser emulators Easy to pick up Can be added to any project any time Can fit any project Can ease post launch task work load once implemented Useful you ask?
11 Goes hand and hand with Behat and Drupal Mink removes API differences between different browser emulators Mink
12 Quick Intro to Behat ntro.html Gherkin Syntax 1.gherkin.html Nice Tutorial d-with-behat--net Step Definitions 2.definitions.html Testing Features Guide 4.context.html Behat Cheatsheet 03-behat-cheat-sheet-en.pdf Resources
Thank You
Arlington Office 1515 N. Courthouse Rd 4 th Floor Arlington, VA Sapientgov.com ov /company/sapient-government- services Thank You Ali McIntosh