Engineering Mechanics Chapter 5 Equilibrium of a Rigid Body
Behat for writing tests in a stylized way
1. Writing tests in a stylized way
@DrupalBangalore - Date 25 July 2015 www.srijan.net
Ravindra Singh
@ravindrasingh01
2. Scenario: Successfully authenticating with correct credentials
Given there is a user “everzet” with password “123”
And I am on the login page
When I fill in “username” with “everzet”
And I fill in “password” with “123”
And I press “login”
Then I should see “Hello, everzet”
In order to get access to the shopping history
As a frequent buyer I need to be able to authenticate
As a buyer I want to see the shopping history
Requirement:
Feature:
Dev Team
Client
3. Scenario: Successfully authenticating with correct credentials
Given there is a user “everzet” with password “123”
And I am on the login page
When I fill in “username” with “everzet”
And I fill in “password” with “123”
And I press “login”
Then I should see “Hello, everzet”
In order to get access to the shopping history
As a frequent buyer I need to be able to authenticate
As a buyer I want to see the shopping history
Requirement:
Feature:
Dev Team
Client
StoryBDD helps ensuring that development
team has understanding of business on the
same level that client does
4. Scenario: Successfully authenticating with correct credentials
Given there is a user “everzet” with password “123”
And I am on the login page
When I fill in “username” with “everzet”
And I fill in “password” with “123”
And I press “login”
Then I should see “Hello, everzet”
In order to get access to the shopping history
As a frequent buyer I need to be able to authenticate
As a buyer I want to see the shopping history
Requirement:
Feature:
Dev Team
Client
5. Agenda
● Introduction to Behat
● Behat Drupal Extension
● Behat Installation/Configuration
● Behat test execution from command line
● A real world example
● How to minimize regressing testing using Behat
6. What is Behat?
● Welcome to Behat! Behat is a tool that makes behavior
driven development(BDD) possible. With BDD, you write
human-readable stories that describe the behavior of your
application. These stories can then be auto-tested against
your application. And yes, it’s as cool as it sounds!
7. Drupal Extension
The Drupal Extension to Behat and Mink assists in the
performance of these common Drupal testing tasks:
● Set up test data with Drush or the Drupal API
● Define theme regions and test data appears within them
● Clear the cache, log out, and other useful steps
● Detect and discover steps provided by contributed
modules and themes
● Detail - https://www.drupal.org/project/drupalextension
8. Installation using Composer
1. Install Composer
2. Install the Drupal Extension in /opt/drupalextension
3. Create an alias to the behat binary in /usr/local/bin
4. Create your test folder
15. Real world example
Feature: H1 Validations
In order to check H1
As visitor
I need to validate headings are in H1 tag
Scenario: Test the ability to find a heading in a
region
Given I go to "http://d8localdev.me/"
When I click "Create new account"
Then I should see the heading "Create new account"
in the "content" region