Behavior-Driven Development
Pravinkumar MR
https://www.drupal.org/u/mrpravin
A step-by-step guide
Agenda
❖ Why automated tests?
❖ BDD - Behavior Driven Development
❖ Gherckin Structure
❖ Demo
❖ Improve the speed
❖ Test coverage
❖ Efficiency
❖ Developers & Testers Motivation
❖ Less Human Resources
❖ Save big money
Why automated tests?
Behavior Driven Development
It is a methodology to support you in
delivering software that matters through
continuous communication, deliberate
discovery and test-automation.
How the customer explained it...
How the project leader understood it...
How the programmers wrote it...
What the customer really needed..
What the tester received ...
example-based communication
Business
and
developers
can clearly
understand
Gherkin
“Defining your behavior”
Gherkin Structure
Feature
http://docs.behat.org/en/v2.5/guides/1.gherkin.html#f
eatures
Scenario
http://docs.behat.org/en/v2.5/guides/1.gherkin.html#
scenarios
Steps
http://docs.behat.org/en/v2.5/guides/1.gherkin.html#
steps
{Test.feature}
Feature
Feature Scenarios
Scenario
Given
Defines the initial state of the system for the scenario
When
Describes the action taken by the person/role
Then
Describes the observable system state after the action has
been performed
And/But
Can be added to create multiple Given/When/Then lines
Feature
Lines starts with Feature keyword followed by three indentended lines.
Contains list of scenarios
Tags are used to group features and scenarios together
A php framework for
autotesting your business
expectations.
.. is a BDD (behavior driven
development) framework for PHP.
Requirements
PHP Higher than 5.3.5
Libraries installed:
- curl
- mbstring
- xml
Behat is a library
easily installed
using composer
1. Run the command
composer require behat/mink-extension behat/mink-goutte-driver
2. Initialize your application by using command
vendor/bin/behat --init
3. implements use BehatBehatContextSnippetAcceptingContext; and
extend use BehatMinkExtensionContextMinkContext;
Ref: http://docs.behat.org/en/v2.5/quick_intro.html#method-1-composer
Ref Mink: http://docs.behat.org/en/v2.5/cookbook/behat_and_mink.html
Behat setup step 1
Behat setup step 2
1. Create a config file called “behat.yml” file.
2. Let, will tell to behat which instance we want to test features.
3. Create a Feature, scenario, steps and run the script….
DEMO
THANKS!
QUESTIONS?

A step-by-step guide to behavior-driven development