Testing Framework based off of Cucumber • Written in PHP • Tests are written in natural language allowing non-technical personnel to participate in the QA process Behat Gherkin Mink Selenium2 Xvfb Firefox
provides a unified API to control a variety of different web browsers: • Goutte - text based, Symfony2 headless browser. No javascript. • Selenium2 - controls most major production browsers Behat Gherkin Mink Selenium2 Xvfb Firefox
specified events in Chrome, Firefox, and Internet Explorer • Uses Google WebDriver to control a web browser programmatically and supports a variety of languages Behat Gherkin Mink Selenium2 Xvfb Firefox
graphical X environment on Linux to run applications without a monitor • Allows us to run Firefox headlessly on a server, enabling automation of tests in a js environment without overhead Behat Gherkin Mink Selenium2 Xvfb Firefox
<app> <module> • Tests are located at: test/features/<app_name>/<module_name>.feature • Each module has its own set of tests, and all the tests for that module are defined in <module_name>.feature
Gherkin which is human readable English • Each test is a scenario defined within a feature; there are usually many scenarios for each feature • To get a list of predefined Gherkin statements that you can use: behat -dl
module • A scenario corresponds to a user interaction with that module and defines a start page, some actions, along with the expected results • A scenario annotated with @javascript will be run using Selenium2 + Firefox
Login In order to interact with the gays.com community As a website user I need to be able to register and login to the site Scenario: Login - success Given I am on "/frontend_dev.php" When I fill in "loginEmail" with "[email protected]" And I fill in "loginPass" with "blabla" And I press "Login" Then I should be on "/frontend_dev.php/main"
order to interact with the gays.com community As a website user I need to be able to register and login to the site Scenario: Login - success Given I am on "/frontend_dev.php" When I fill in "loginEmail" with "[email protected]" And I fill in "loginPass" with "blabla" And I perform a custom task with “parameter” And I press "Login" Then I should be on "/frontend_dev.php/main"
and Login In order to interact with the gays.com community As a website user I need to be able to register and login to the site Scenario: Login - success # start.feature:6 Given I am on "/frontend_dev.php" # FeatureContext::visit() When I fill in "loginEmail" with "[email protected]" # FeatureContext::fillField() And I fill in "loginPass" with "blabla" # FeatureContext::fillField() And I run a custom task with "parameter" And I press "Login" # FeatureContext::pressButton() Then I should be on "/frontend_dev.php/main" # FeatureContext::assertPageAddress() 1 scenario (1 undefined) 6 steps (3 passed, 2 skipped, 1 undefined) 0m6.031s You can implement step definitions for undefined steps with these snippets: /** * @Given /^I run a custom task with "([^"]*)"$/ */ public function iRunACustomTaskWith($argument1) { throw new PendingException(); }
extends Behat\Mink\Behat\Context\MinkContext { public function __construct($params) { parent::__construct($params); } /** * @Given /^I run a custom task with "([^"]*)"$/ */ public function iRunACustomTaskWith($argument1) { echo "I'm going to print now: $argument1\n"; } }
Registration and Login In order to interact with the gays.com community As a website user I need to be able to register and login to the site Scenario: Login - success # start.feature:6 Given I am on "/frontend_dev.php" # FeatureContext::visit() When I fill in "loginEmail" with "[email protected]" # FeatureContext::fillField() And I fill in "loginPass" with "blabla" # FeatureContext::fillField() I'm going to print now: parameter And I run a custom task with "parameter" And I press "Login" # FeatureContext::pressButton() Then I should be on "/frontend_dev.php/main" # FeatureContext::assertPageAddress() 1 scenario (1 passed) 5 steps (5 passed) 0m5.408s $