SlideShare a Scribd company logo
1 of 51
Session Breakdown
Preface (this)
Intro to BDD
Intro to Behat
Build some Tests
Why Are You Here?
What is your role in the development lifecycle?
What is your reason for attending this session?
What do you hope to get out of this session?
What is your experience level with PHP, Behat,
and BDD?
Pre-Run Checklist
Make sure you have:
PHP 5.6+
Composer
A browser with the Selenium driver
Selenium Server Standalone (Optional for 2.x)
Gotchas
Missing one of these extensions:
curl
mbstring
openssl
No default timezone in PHP.ini
What is BDD?
BDD is business driven, user focused, and test first.
It focuses on delivering business value as effectively
and efficiently as possible while maintaining
consistent quality throughout the entire application.
BDD is a methodology built around the principles of
lean development, extreme programming, test driven
development, and domain driven design.
What BDD Provides
Better understanding of the business requirement for
development and QA
Better understanding of existing features for the
business
Better communication via a ubiquitous language
Real insight into the business effect of a defect
What BDD Doesn’t Provide
The answer to all your problems
A replacement for unit testing
A replacement for manual testing
Super easy to implement everywhere right this second
A measure of code quality
Failed to Assert False is True
or
How I learned to love BDD
Stay Focused
It is crucial to the success of BDD to focus on what
value a feature provides to the business.
Always understand the the role of the user and
their relationship to the feature.
Do not get distracted by the technical aspects of
the implementation.
Story BDD Hierarchy
Feature
Background
Scenario
Step Step
Scenario
Step Step
Writing Features
Applications are comprised of features
BDD discretely separates each feature
Each feature contains a narrative and a scenario
Feature may also contain a background to set the
stage for the feature scenarios
Narrative
Feature narratives are written similarly to Agile/Scrum
stories and must answer these questions:
What is the business benefit?
Who is the beneficiary?
What is the action performed?
Background
A background should contain steps common to all, or
at least most, scenarios to prepare the application
environment for the scenarios.
Background steps should be tested elsewhere as part
of another feature.
Steps failing in the background steps will identify that
the failure is not related to the feature.
Scenario
A scenarios should contain a narrative
Scenarios work in a manner similar to unit tests by arranging
the environment necessary to begin the test, perform
actions, and then assert that the expected results have been
attained
Scenarios should not test multiple features. Do not perform
actions after assertions.
Scenario Outline
Scenario outlines use a common set of steps with
placeholders for data provided in a data table.
They are a replacement for multiple scenarios in which
data is the only differentiator and does not define the
feature. Adding sales tax would be an example of a
feature in which the data in the action and assertion
would be different.
Step
Steps do one of the following:
Arrange the environment
Perform an action
Assert a result of the previous actions
Steps should be reasonably reusable
Steps should be aggregated for simplification when
arranging the environment
What is Behat?
Open source Behavior Driven Development
framework for PHP
Official PHP implementation of Cucumber
One of the easiest Cucumber implementations to
get up and running quickly
Good documentation: http://docs.behat.org
Installation
PHAR installation
Single global install
One version for feature contexts
Project Installation
Composer based install as dependency
Version and dependencies tied to project
Components
Command line executable – behat
Configuration file – behat.yml
Feature context(s)
Feature Files
Command Line Executable
Allows for initializing the environment
Running features
Features and scenarios filterable by tags
Chooses environment
Listing step definitions
Configuration File
Split up into profiles
(inherit from default)
Configures custom
autoloader path
Defines global tag filters
Defines output
formatters
Defines feature suites
Configures extensions
Feature Context
Defines steps
May extend other contexts
May access other contexts
May add hooks for pre/post tag, step, scenario,
feature, and suite execution.
Gherkin
Gherkin is a Domain Specific Language (DSL)
utilized to write Features in Behat. It uses key words
to identify the type of step:
Given – Arrange
When – Act
Then - Assert
Example Gherkin
Feature: Home Page
Scenario: Login Link
Given I am on the homepage
When I click " Login"
Then I will be on the "LaunchKey | Log in"
page
Step Backing Code
Method on a feature context
Contains doc block annotated (@) matchers
Support defined in context. Defaults to Turnip
Supports Turnip and regular expressions
Can contain examples doc block
Can contain descript in the doc block
Example Step
/**
* Opens homepage
* Example: Given I am on "/"
* Example: When I go to "/"
* Example: And I go to "/”
* @Given (I )am on :path
* @When (I )go to :path
*/
public function visitPath($path)
{
$this->browser->open($path);
}
Create a Project
Composer “init”
Add requirements
Behat “init”
Add Contexts to Config
Verify Your Install
Run “vendor/bin/behat –h”
You should see the help text
Initialize Behat
Initialize the behat project via the Behat CLI
with the --init flag
Verify by running “vendor/bin/behat”
Add Mink to Config
• Add the extension to the default profile
• Set the base URL
• Add the drivers
Add Contexts to Config
• Add Mink context to get access to pre-built
browser steps
• Add project context to make custom steps
Verify Configuration
Run “vendor/bin/behat –dl”
You should see a LOT of steps
Run “vendor/bin/behat –di”
You should see additional information for the
steps
Lets Write A Feature Test
User Story:
In order to use the site
As a site visitor
I can access the website
Let’s Make Another
Requirement:
In order to be a user
As a visitor
I can register for a user account
What About Clean Up
Requirement:
E-Mail Address is the user identifier and must be
unique among all users
We’re going to have to clean up users in a hook
Steps Need to Be Intuitive
Checking for errors on registration submission
will require a custom step with some additional
logic
Add Other Requirements
E-Mail Address is the user identifier and must be
unique among all users
Name is required and captures the users name
Password is required and must utilize a verification
field to ensure correct password entry
Finish Up Labs/Examples
Server and Behat features found in GitHub:
https://github.com/aenglander/bdd-with-behat-for-
beginners
Master branch is Behat
Master is tagged to go step by step
Server branch is server
Selenium
Industry standard
Server with remote API
Direct integration with Behat/Mink via Selenium
Driver
Can be used headless with PhantomJS via
GhostDriver implementation
Using Selenium Server
Add config to bahat.yml and specify browser
Apply @javascript tag to scenarios or a feature
Start Selenium Standalone Server
Run tests
Selenium Grid
Allows for multiple simultaneous test runs, multiple
browser versions, and multiple operating systems
One Hub and Multiple Nodes
Uses same app as Standalone Server
Can be flakey and hard to manage
Sauce Labs/BrowserStack
Special Drivers for Sauce Labs and
BrowserStack
Not well documented but work very well
Allow for a “Grid” style environment without
managing the Grid
Configuring Mink Driver
Poorly documented
Easy to figure out the settings by looking at the
driver factories. See:
vendor/behat/mink-
extension/src/Behat/MinkExtension/ServiceContainer
/Driver
Best Practices
Feature files contain one Feature
Features should be more business than
technical focused
Best Practices (cont.)
Use the three A’s
Arrange – Background – Given
Act – When
Assert - Then
Best Practices (cont.)
Make steps visually verifiable. Feature files
should be able to serve as documentation
Clean up after yourself
Scenarios should be idempotent
Spend the time to do it the right way

More Related Content

What's hot

Behavior driven development - cucumber, Junit and java
Behavior driven development - cucumber, Junit and javaBehavior driven development - cucumber, Junit and java
Behavior driven development - cucumber, Junit and javaNaveen Kumar Singh
 
BDD with SpecFlow and Selenium
BDD with SpecFlow and SeleniumBDD with SpecFlow and Selenium
BDD with SpecFlow and SeleniumLiraz Shay
 
Introduction to Bdd and cucumber
Introduction to Bdd and cucumberIntroduction to Bdd and cucumber
Introduction to Bdd and cucumberNibu Baby
 
Getting Started with Zend Framework
Getting Started with Zend FrameworkGetting Started with Zend Framework
Getting Started with Zend FrameworkJuan Antonio
 
Rich GUI Testing: Swing and JavaFX
Rich GUI Testing: Swing and JavaFXRich GUI Testing: Swing and JavaFX
Rich GUI Testing: Swing and JavaFXAlex Ruiz
 
Behaviour Driven Development
Behaviour Driven DevelopmentBehaviour Driven Development
Behaviour Driven DevelopmentRichard Ruiter
 
Behavior Driven Development with SpecFlow
Behavior Driven Development with SpecFlowBehavior Driven Development with SpecFlow
Behavior Driven Development with SpecFlowRachid Kherrazi
 
Test and Behaviour Driven Development (TDD/BDD)
Test and Behaviour Driven Development (TDD/BDD)Test and Behaviour Driven Development (TDD/BDD)
Test and Behaviour Driven Development (TDD/BDD)Lars Thorup
 
Improve your development skills with Test Driven Development
Improve your development skills with Test Driven DevelopmentImprove your development skills with Test Driven Development
Improve your development skills with Test Driven DevelopmentJohn Stevenson
 
AngularJS Beginner Day One
AngularJS Beginner Day OneAngularJS Beginner Day One
AngularJS Beginner Day OneTroy Miles
 
ATDD in Practice
ATDD in PracticeATDD in Practice
ATDD in PracticeSteven Mak
 
Sergey Pirogov "Test coverage myth busted"
Sergey Pirogov "Test coverage myth busted"Sergey Pirogov "Test coverage myth busted"
Sergey Pirogov "Test coverage myth busted"Fwdays
 

What's hot (19)

Behavior driven development - cucumber, Junit and java
Behavior driven development - cucumber, Junit and javaBehavior driven development - cucumber, Junit and java
Behavior driven development - cucumber, Junit and java
 
Using Specflow for BDD
Using Specflow for BDDUsing Specflow for BDD
Using Specflow for BDD
 
SpecFlow for Agile Teams
SpecFlow for Agile TeamsSpecFlow for Agile Teams
SpecFlow for Agile Teams
 
BDD with JBehave
BDD with JBehaveBDD with JBehave
BDD with JBehave
 
BDD with SpecFlow and Selenium
BDD with SpecFlow and SeleniumBDD with SpecFlow and Selenium
BDD with SpecFlow and Selenium
 
Introduction to Bdd and cucumber
Introduction to Bdd and cucumberIntroduction to Bdd and cucumber
Introduction to Bdd and cucumber
 
BDD for APIs
BDD for APIsBDD for APIs
BDD for APIs
 
Serenity-BDD training
Serenity-BDD trainingSerenity-BDD training
Serenity-BDD training
 
Getting Started with Zend Framework
Getting Started with Zend FrameworkGetting Started with Zend Framework
Getting Started with Zend Framework
 
Cucumber BDD
Cucumber BDDCucumber BDD
Cucumber BDD
 
Rich GUI Testing: Swing and JavaFX
Rich GUI Testing: Swing and JavaFXRich GUI Testing: Swing and JavaFX
Rich GUI Testing: Swing and JavaFX
 
Behaviour Driven Development
Behaviour Driven DevelopmentBehaviour Driven Development
Behaviour Driven Development
 
Behavior Driven Development with SpecFlow
Behavior Driven Development with SpecFlowBehavior Driven Development with SpecFlow
Behavior Driven Development with SpecFlow
 
Test and Behaviour Driven Development (TDD/BDD)
Test and Behaviour Driven Development (TDD/BDD)Test and Behaviour Driven Development (TDD/BDD)
Test and Behaviour Driven Development (TDD/BDD)
 
Improve your development skills with Test Driven Development
Improve your development skills with Test Driven DevelopmentImprove your development skills with Test Driven Development
Improve your development skills with Test Driven Development
 
AngularJS Beginner Day One
AngularJS Beginner Day OneAngularJS Beginner Day One
AngularJS Beginner Day One
 
ATDD in Practice
ATDD in PracticeATDD in Practice
ATDD in Practice
 
Jbehave selenium
Jbehave seleniumJbehave selenium
Jbehave selenium
 
Sergey Pirogov "Test coverage myth busted"
Sergey Pirogov "Test coverage myth busted"Sergey Pirogov "Test coverage myth busted"
Sergey Pirogov "Test coverage myth busted"
 

Viewers also liked

SEÇÃO Nº 20
SEÇÃO Nº 20SEÇÃO Nº 20
SEÇÃO Nº 20Jerbialdo
 
MATERI KELAS XII PKn
MATERI KELAS XII PKnMATERI KELAS XII PKn
MATERI KELAS XII PKnmaryuni ,.
 
Professional Development`
Professional Development`Professional Development`
Professional Development`Francisco Gomez
 
Mike pence's 2016 state of the state address
Mike pence's 2016 state of the state addressMike pence's 2016 state of the state address
Mike pence's 2016 state of the state addressAbdul-Hakim Shabazz
 
SEÇÃO Nº 17 (agregada à seção 18)
SEÇÃO Nº   17  (agregada à seção 18)SEÇÃO Nº   17  (agregada à seção 18)
SEÇÃO Nº 17 (agregada à seção 18)Jerbialdo
 
SEÇÃO Nº 202
SEÇÃO Nº 202SEÇÃO Nº 202
SEÇÃO Nº 202Jerbialdo
 
DIÁRIO OFICIAL DO MUNICÍPIO (PREFEITURA MUNICIPAL DE DÁRIO MEIRA)
DIÁRIO OFICIAL DO MUNICÍPIO (PREFEITURA MUNICIPAL DE DÁRIO MEIRA)DIÁRIO OFICIAL DO MUNICÍPIO (PREFEITURA MUNICIPAL DE DÁRIO MEIRA)
DIÁRIO OFICIAL DO MUNICÍPIO (PREFEITURA MUNICIPAL DE DÁRIO MEIRA)Jerbialdo
 
Nearshore Best Practices Workshop
Nearshore Best Practices WorkshopNearshore Best Practices Workshop
Nearshore Best Practices WorkshopVelocity Partners
 
The sentence, the phrase and the clause
The sentence, the phrase and the clauseThe sentence, the phrase and the clause
The sentence, the phrase and the clauseBrett Provance
 
Zend con 2016 - Asynchronous Prorgamming in PHP
Zend con 2016 - Asynchronous Prorgamming in PHPZend con 2016 - Asynchronous Prorgamming in PHP
Zend con 2016 - Asynchronous Prorgamming in PHPAdam Englander
 
Slide de futsal para aula de ed. física
Slide de futsal para aula de ed. físicaSlide de futsal para aula de ed. física
Slide de futsal para aula de ed. físicaadnete
 
Indikator soal p kn xi
Indikator soal p kn xiIndikator soal p kn xi
Indikator soal p kn ximaryuni ,.
 

Viewers also liked (20)

Haa iup workshop_uh
Haa iup workshop_uhHaa iup workshop_uh
Haa iup workshop_uh
 
Resume
ResumeResume
Resume
 
Hubspot Software Cert
Hubspot Software CertHubspot Software Cert
Hubspot Software Cert
 
SEÇÃO Nº 20
SEÇÃO Nº 20SEÇÃO Nº 20
SEÇÃO Nº 20
 
Judge Halts Indiana Vaping Law
Judge Halts Indiana Vaping LawJudge Halts Indiana Vaping Law
Judge Halts Indiana Vaping Law
 
MATERI KELAS XII PKn
MATERI KELAS XII PKnMATERI KELAS XII PKn
MATERI KELAS XII PKn
 
Professional Development`
Professional Development`Professional Development`
Professional Development`
 
Mike pence's 2016 state of the state address
Mike pence's 2016 state of the state addressMike pence's 2016 state of the state address
Mike pence's 2016 state of the state address
 
Bab 5
Bab 5Bab 5
Bab 5
 
Sep 15
Sep 15Sep 15
Sep 15
 
SEÇÃO Nº 17 (agregada à seção 18)
SEÇÃO Nº   17  (agregada à seção 18)SEÇÃO Nº   17  (agregada à seção 18)
SEÇÃO Nº 17 (agregada à seção 18)
 
Uhm iup workshop introduction
Uhm iup workshop introductionUhm iup workshop introduction
Uhm iup workshop introduction
 
SEÇÃO Nº 202
SEÇÃO Nº 202SEÇÃO Nº 202
SEÇÃO Nº 202
 
DIÁRIO OFICIAL DO MUNICÍPIO (PREFEITURA MUNICIPAL DE DÁRIO MEIRA)
DIÁRIO OFICIAL DO MUNICÍPIO (PREFEITURA MUNICIPAL DE DÁRIO MEIRA)DIÁRIO OFICIAL DO MUNICÍPIO (PREFEITURA MUNICIPAL DE DÁRIO MEIRA)
DIÁRIO OFICIAL DO MUNICÍPIO (PREFEITURA MUNICIPAL DE DÁRIO MEIRA)
 
Nearshore Best Practices Workshop
Nearshore Best Practices WorkshopNearshore Best Practices Workshop
Nearshore Best Practices Workshop
 
2nd Grade
2nd Grade 2nd Grade
2nd Grade
 
The sentence, the phrase and the clause
The sentence, the phrase and the clauseThe sentence, the phrase and the clause
The sentence, the phrase and the clause
 
Zend con 2016 - Asynchronous Prorgamming in PHP
Zend con 2016 - Asynchronous Prorgamming in PHPZend con 2016 - Asynchronous Prorgamming in PHP
Zend con 2016 - Asynchronous Prorgamming in PHP
 
Slide de futsal para aula de ed. física
Slide de futsal para aula de ed. físicaSlide de futsal para aula de ed. física
Slide de futsal para aula de ed. física
 
Indikator soal p kn xi
Indikator soal p kn xiIndikator soal p kn xi
Indikator soal p kn xi
 

Similar to PHPConf.asia 2016 - BDD with Behat for Beginners

Zend con 2016 bdd with behat for beginners
Zend con 2016   bdd with behat for beginnersZend con 2016   bdd with behat for beginners
Zend con 2016 bdd with behat for beginnersAdam Englander
 
CucumberSeleniumWD
CucumberSeleniumWDCucumberSeleniumWD
CucumberSeleniumWDVikas Sarin
 
Strategies and Tips for Building Enterprise Drupal Applications - PNWDS 2013
Strategies and Tips for Building Enterprise Drupal Applications - PNWDS 2013Strategies and Tips for Building Enterprise Drupal Applications - PNWDS 2013
Strategies and Tips for Building Enterprise Drupal Applications - PNWDS 2013Mack Hardy
 
Php[tek] 2016 - BDD with Behat for Beginners
Php[tek] 2016 - BDD with Behat for BeginnersPhp[tek] 2016 - BDD with Behat for Beginners
Php[tek] 2016 - BDD with Behat for BeginnersAdam Englander
 
BDD Selenium for Agile Teams - User Stories
BDD Selenium for Agile Teams - User StoriesBDD Selenium for Agile Teams - User Stories
BDD Selenium for Agile Teams - User StoriesSauce Labs
 
Automated Acceptance Tests & Tool choice
Automated Acceptance Tests & Tool choiceAutomated Acceptance Tests & Tool choice
Automated Acceptance Tests & Tool choicetoddbr
 
Introducing BDD and TDD with Cucumber
Introducing BDD and TDD with CucumberIntroducing BDD and TDD with Cucumber
Introducing BDD and TDD with CucumberKnoldus Inc.
 
Behavior Driven Development
Behavior Driven DevelopmentBehavior Driven Development
Behavior Driven DevelopmentMonocularVision
 
Behaviour Driven Development V 0.1
Behaviour Driven Development V 0.1Behaviour Driven Development V 0.1
Behaviour Driven Development V 0.1willmation
 
SPCA2013 - Test-driven Development with SharePoint 2013 and Visual Studio
SPCA2013 - Test-driven Development with SharePoint 2013 and Visual StudioSPCA2013 - Test-driven Development with SharePoint 2013 and Visual Studio
SPCA2013 - Test-driven Development with SharePoint 2013 and Visual StudioNCCOMMS
 
Joomla! Day Chicago 2011 Presentation - Steven Pignataro
Joomla! Day Chicago 2011 Presentation - Steven PignataroJoomla! Day Chicago 2011 Presentation - Steven Pignataro
Joomla! Day Chicago 2011 Presentation - Steven PignataroSteven Pignataro
 
Behavior Driven Testing with SpecFlow
Behavior Driven Testing with SpecFlowBehavior Driven Testing with SpecFlow
Behavior Driven Testing with SpecFlowRachid Kherrazi
 
Slides from LAX & DEN usergroup meetings
Slides from LAX & DEN usergroup meetingsSlides from LAX & DEN usergroup meetings
Slides from LAX & DEN usergroup meetings10n Software, LLC
 
Software Development Standard Operating Procedure
Software Development Standard Operating Procedure Software Development Standard Operating Procedure
Software Development Standard Operating Procedure rupeshchanchal
 
The "Holy Grail" of Dev/Ops
The "Holy Grail" of Dev/OpsThe "Holy Grail" of Dev/Ops
The "Holy Grail" of Dev/OpsErik Osterman
 
TDD with BizTalk
TDD with BizTalkTDD with BizTalk
TDD with BizTalkBen Carey
 
MuleSoft Nashik Virtual Meetup#4 - Implementing CI/CD pipeline for deploying ...
MuleSoft Nashik Virtual Meetup#4 - Implementing CI/CD pipeline for deploying ...MuleSoft Nashik Virtual Meetup#4 - Implementing CI/CD pipeline for deploying ...
MuleSoft Nashik Virtual Meetup#4 - Implementing CI/CD pipeline for deploying ...Jitendra Bafna
 
Lightning Talks by Globant - Automation (This app runs by itself )
Lightning Talks by Globant -  Automation (This app runs by itself ) Lightning Talks by Globant -  Automation (This app runs by itself )
Lightning Talks by Globant - Automation (This app runs by itself ) Globant
 

Similar to PHPConf.asia 2016 - BDD with Behat for Beginners (20)

Zend con 2016 bdd with behat for beginners
Zend con 2016   bdd with behat for beginnersZend con 2016   bdd with behat for beginners
Zend con 2016 bdd with behat for beginners
 
Gherkin /BDD intro
Gherkin /BDD introGherkin /BDD intro
Gherkin /BDD intro
 
CucumberSeleniumWD
CucumberSeleniumWDCucumberSeleniumWD
CucumberSeleniumWD
 
Strategies and Tips for Building Enterprise Drupal Applications - PNWDS 2013
Strategies and Tips for Building Enterprise Drupal Applications - PNWDS 2013Strategies and Tips for Building Enterprise Drupal Applications - PNWDS 2013
Strategies and Tips for Building Enterprise Drupal Applications - PNWDS 2013
 
Cucumber_Training_ForQA
Cucumber_Training_ForQACucumber_Training_ForQA
Cucumber_Training_ForQA
 
Php[tek] 2016 - BDD with Behat for Beginners
Php[tek] 2016 - BDD with Behat for BeginnersPhp[tek] 2016 - BDD with Behat for Beginners
Php[tek] 2016 - BDD with Behat for Beginners
 
BDD Selenium for Agile Teams - User Stories
BDD Selenium for Agile Teams - User StoriesBDD Selenium for Agile Teams - User Stories
BDD Selenium for Agile Teams - User Stories
 
Automated Acceptance Tests & Tool choice
Automated Acceptance Tests & Tool choiceAutomated Acceptance Tests & Tool choice
Automated Acceptance Tests & Tool choice
 
Introducing BDD and TDD with Cucumber
Introducing BDD and TDD with CucumberIntroducing BDD and TDD with Cucumber
Introducing BDD and TDD with Cucumber
 
Behavior Driven Development
Behavior Driven DevelopmentBehavior Driven Development
Behavior Driven Development
 
Behaviour Driven Development V 0.1
Behaviour Driven Development V 0.1Behaviour Driven Development V 0.1
Behaviour Driven Development V 0.1
 
SPCA2013 - Test-driven Development with SharePoint 2013 and Visual Studio
SPCA2013 - Test-driven Development with SharePoint 2013 and Visual StudioSPCA2013 - Test-driven Development with SharePoint 2013 and Visual Studio
SPCA2013 - Test-driven Development with SharePoint 2013 and Visual Studio
 
Joomla! Day Chicago 2011 Presentation - Steven Pignataro
Joomla! Day Chicago 2011 Presentation - Steven PignataroJoomla! Day Chicago 2011 Presentation - Steven Pignataro
Joomla! Day Chicago 2011 Presentation - Steven Pignataro
 
Behavior Driven Testing with SpecFlow
Behavior Driven Testing with SpecFlowBehavior Driven Testing with SpecFlow
Behavior Driven Testing with SpecFlow
 
Slides from LAX & DEN usergroup meetings
Slides from LAX & DEN usergroup meetingsSlides from LAX & DEN usergroup meetings
Slides from LAX & DEN usergroup meetings
 
Software Development Standard Operating Procedure
Software Development Standard Operating Procedure Software Development Standard Operating Procedure
Software Development Standard Operating Procedure
 
The "Holy Grail" of Dev/Ops
The "Holy Grail" of Dev/OpsThe "Holy Grail" of Dev/Ops
The "Holy Grail" of Dev/Ops
 
TDD with BizTalk
TDD with BizTalkTDD with BizTalk
TDD with BizTalk
 
MuleSoft Nashik Virtual Meetup#4 - Implementing CI/CD pipeline for deploying ...
MuleSoft Nashik Virtual Meetup#4 - Implementing CI/CD pipeline for deploying ...MuleSoft Nashik Virtual Meetup#4 - Implementing CI/CD pipeline for deploying ...
MuleSoft Nashik Virtual Meetup#4 - Implementing CI/CD pipeline for deploying ...
 
Lightning Talks by Globant - Automation (This app runs by itself )
Lightning Talks by Globant -  Automation (This app runs by itself ) Lightning Talks by Globant -  Automation (This app runs by itself )
Lightning Talks by Globant - Automation (This app runs by itself )
 

More from Adam Englander

Making PHP Smarter - Dutch PHP 2023.pptx
Making PHP Smarter - Dutch PHP 2023.pptxMaking PHP Smarter - Dutch PHP 2023.pptx
Making PHP Smarter - Dutch PHP 2023.pptxAdam Englander
 
Practical API Security - PyCon 2019
Practical API Security - PyCon 2019Practical API Security - PyCon 2019
Practical API Security - PyCon 2019Adam Englander
 
Threat Modeling for Dummies
Threat Modeling for DummiesThreat Modeling for Dummies
Threat Modeling for DummiesAdam Englander
 
ZendCon 2018 - Practical API Security
ZendCon 2018 - Practical API SecurityZendCon 2018 - Practical API Security
ZendCon 2018 - Practical API SecurityAdam Englander
 
ZendCon 2018 - Cryptography in Depth
ZendCon 2018 - Cryptography in DepthZendCon 2018 - Cryptography in Depth
ZendCon 2018 - Cryptography in DepthAdam Englander
 
Threat Modeling for Dummies - Cascadia PHP 2018
Threat Modeling for Dummies - Cascadia PHP 2018Threat Modeling for Dummies - Cascadia PHP 2018
Threat Modeling for Dummies - Cascadia PHP 2018Adam Englander
 
Dutch PHP 2018 - Cryptography for Beginners
Dutch PHP 2018 - Cryptography for BeginnersDutch PHP 2018 - Cryptography for Beginners
Dutch PHP 2018 - Cryptography for BeginnersAdam Englander
 
php[tek] 2108 - Cryptography Advances in PHP 7.2
php[tek] 2108 - Cryptography Advances in PHP 7.2php[tek] 2108 - Cryptography Advances in PHP 7.2
php[tek] 2108 - Cryptography Advances in PHP 7.2Adam Englander
 
php[tek] 2018 - Biometrics, fantastic failure point of the future
php[tek] 2018 - Biometrics, fantastic failure point of the futurephp[tek] 2018 - Biometrics, fantastic failure point of the future
php[tek] 2018 - Biometrics, fantastic failure point of the futureAdam Englander
 
Biometrics: Sexy, Secure and... Stupid - RSAC 2018
Biometrics: Sexy, Secure and... Stupid - RSAC 2018Biometrics: Sexy, Secure and... Stupid - RSAC 2018
Biometrics: Sexy, Secure and... Stupid - RSAC 2018Adam Englander
 
Practical API Security - PyCon 2018
Practical API Security - PyCon 2018Practical API Security - PyCon 2018
Practical API Security - PyCon 2018Adam Englander
 
Practical API Security - Midwest PHP 2018
Practical API Security - Midwest PHP 2018Practical API Security - Midwest PHP 2018
Practical API Security - Midwest PHP 2018Adam Englander
 
Cryptography for Beginners - Midwest PHP 2018
Cryptography for Beginners - Midwest PHP 2018Cryptography for Beginners - Midwest PHP 2018
Cryptography for Beginners - Midwest PHP 2018Adam Englander
 
Cryptography for Beginners - Sunshine PHP 2018
Cryptography for Beginners - Sunshine PHP 2018Cryptography for Beginners - Sunshine PHP 2018
Cryptography for Beginners - Sunshine PHP 2018Adam Englander
 
ConFoo Vancouver 2017 - Biometrics: Fantastic Failure Point of the Future
ConFoo Vancouver 2017 - Biometrics: Fantastic Failure Point of the FutureConFoo Vancouver 2017 - Biometrics: Fantastic Failure Point of the Future
ConFoo Vancouver 2017 - Biometrics: Fantastic Failure Point of the FutureAdam Englander
 
Con Foo 2017 - Don't Loose Sleep - Secure Your REST
Con Foo 2017 - Don't Loose Sleep - Secure Your RESTCon Foo 2017 - Don't Loose Sleep - Secure Your REST
Con Foo 2017 - Don't Loose Sleep - Secure Your RESTAdam Englander
 
ZendCon 2017 - Cryptography for Beginners
ZendCon 2017 - Cryptography for BeginnersZendCon 2017 - Cryptography for Beginners
ZendCon 2017 - Cryptography for BeginnersAdam Englander
 
ZendCon 2017: The Red Team is Coming
ZendCon 2017: The Red Team is ComingZendCon 2017: The Red Team is Coming
ZendCon 2017: The Red Team is ComingAdam Englander
 
ZendCon 2017 - Build a Bot Workshop - Async Primer
ZendCon 2017 - Build a Bot Workshop - Async PrimerZendCon 2017 - Build a Bot Workshop - Async Primer
ZendCon 2017 - Build a Bot Workshop - Async PrimerAdam Englander
 
Symfony Live San Franciso 2017 - BDD API Development with Symfony and Behat
Symfony Live San Franciso 2017 - BDD API Development with Symfony and BehatSymfony Live San Franciso 2017 - BDD API Development with Symfony and Behat
Symfony Live San Franciso 2017 - BDD API Development with Symfony and BehatAdam Englander
 

More from Adam Englander (20)

Making PHP Smarter - Dutch PHP 2023.pptx
Making PHP Smarter - Dutch PHP 2023.pptxMaking PHP Smarter - Dutch PHP 2023.pptx
Making PHP Smarter - Dutch PHP 2023.pptx
 
Practical API Security - PyCon 2019
Practical API Security - PyCon 2019Practical API Security - PyCon 2019
Practical API Security - PyCon 2019
 
Threat Modeling for Dummies
Threat Modeling for DummiesThreat Modeling for Dummies
Threat Modeling for Dummies
 
ZendCon 2018 - Practical API Security
ZendCon 2018 - Practical API SecurityZendCon 2018 - Practical API Security
ZendCon 2018 - Practical API Security
 
ZendCon 2018 - Cryptography in Depth
ZendCon 2018 - Cryptography in DepthZendCon 2018 - Cryptography in Depth
ZendCon 2018 - Cryptography in Depth
 
Threat Modeling for Dummies - Cascadia PHP 2018
Threat Modeling for Dummies - Cascadia PHP 2018Threat Modeling for Dummies - Cascadia PHP 2018
Threat Modeling for Dummies - Cascadia PHP 2018
 
Dutch PHP 2018 - Cryptography for Beginners
Dutch PHP 2018 - Cryptography for BeginnersDutch PHP 2018 - Cryptography for Beginners
Dutch PHP 2018 - Cryptography for Beginners
 
php[tek] 2108 - Cryptography Advances in PHP 7.2
php[tek] 2108 - Cryptography Advances in PHP 7.2php[tek] 2108 - Cryptography Advances in PHP 7.2
php[tek] 2108 - Cryptography Advances in PHP 7.2
 
php[tek] 2018 - Biometrics, fantastic failure point of the future
php[tek] 2018 - Biometrics, fantastic failure point of the futurephp[tek] 2018 - Biometrics, fantastic failure point of the future
php[tek] 2018 - Biometrics, fantastic failure point of the future
 
Biometrics: Sexy, Secure and... Stupid - RSAC 2018
Biometrics: Sexy, Secure and... Stupid - RSAC 2018Biometrics: Sexy, Secure and... Stupid - RSAC 2018
Biometrics: Sexy, Secure and... Stupid - RSAC 2018
 
Practical API Security - PyCon 2018
Practical API Security - PyCon 2018Practical API Security - PyCon 2018
Practical API Security - PyCon 2018
 
Practical API Security - Midwest PHP 2018
Practical API Security - Midwest PHP 2018Practical API Security - Midwest PHP 2018
Practical API Security - Midwest PHP 2018
 
Cryptography for Beginners - Midwest PHP 2018
Cryptography for Beginners - Midwest PHP 2018Cryptography for Beginners - Midwest PHP 2018
Cryptography for Beginners - Midwest PHP 2018
 
Cryptography for Beginners - Sunshine PHP 2018
Cryptography for Beginners - Sunshine PHP 2018Cryptography for Beginners - Sunshine PHP 2018
Cryptography for Beginners - Sunshine PHP 2018
 
ConFoo Vancouver 2017 - Biometrics: Fantastic Failure Point of the Future
ConFoo Vancouver 2017 - Biometrics: Fantastic Failure Point of the FutureConFoo Vancouver 2017 - Biometrics: Fantastic Failure Point of the Future
ConFoo Vancouver 2017 - Biometrics: Fantastic Failure Point of the Future
 
Con Foo 2017 - Don't Loose Sleep - Secure Your REST
Con Foo 2017 - Don't Loose Sleep - Secure Your RESTCon Foo 2017 - Don't Loose Sleep - Secure Your REST
Con Foo 2017 - Don't Loose Sleep - Secure Your REST
 
ZendCon 2017 - Cryptography for Beginners
ZendCon 2017 - Cryptography for BeginnersZendCon 2017 - Cryptography for Beginners
ZendCon 2017 - Cryptography for Beginners
 
ZendCon 2017: The Red Team is Coming
ZendCon 2017: The Red Team is ComingZendCon 2017: The Red Team is Coming
ZendCon 2017: The Red Team is Coming
 
ZendCon 2017 - Build a Bot Workshop - Async Primer
ZendCon 2017 - Build a Bot Workshop - Async PrimerZendCon 2017 - Build a Bot Workshop - Async Primer
ZendCon 2017 - Build a Bot Workshop - Async Primer
 
Symfony Live San Franciso 2017 - BDD API Development with Symfony and Behat
Symfony Live San Franciso 2017 - BDD API Development with Symfony and BehatSymfony Live San Franciso 2017 - BDD API Development with Symfony and Behat
Symfony Live San Franciso 2017 - BDD API Development with Symfony and Behat
 

Recently uploaded

A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructureitnewsafrica
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPathCommunity
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integrationmarketing932765
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationKnoldus Inc.
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Kaya Weers
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024TopCSSGallery
 
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesBernd Ruecker
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesManik S Magar
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...Wes McKinney
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Nikki Chapple
 

Recently uploaded (20)

A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to Hero
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog Presentation
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024
 
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architectures
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
 

PHPConf.asia 2016 - BDD with Behat for Beginners

  • 1.
  • 2. Session Breakdown Preface (this) Intro to BDD Intro to Behat Build some Tests
  • 3. Why Are You Here? What is your role in the development lifecycle? What is your reason for attending this session? What do you hope to get out of this session? What is your experience level with PHP, Behat, and BDD?
  • 4. Pre-Run Checklist Make sure you have: PHP 5.6+ Composer A browser with the Selenium driver Selenium Server Standalone (Optional for 2.x)
  • 5. Gotchas Missing one of these extensions: curl mbstring openssl No default timezone in PHP.ini
  • 6.
  • 7. What is BDD? BDD is business driven, user focused, and test first. It focuses on delivering business value as effectively and efficiently as possible while maintaining consistent quality throughout the entire application. BDD is a methodology built around the principles of lean development, extreme programming, test driven development, and domain driven design.
  • 8. What BDD Provides Better understanding of the business requirement for development and QA Better understanding of existing features for the business Better communication via a ubiquitous language Real insight into the business effect of a defect
  • 9. What BDD Doesn’t Provide The answer to all your problems A replacement for unit testing A replacement for manual testing Super easy to implement everywhere right this second A measure of code quality
  • 10. Failed to Assert False is True or How I learned to love BDD
  • 11.
  • 12. Stay Focused It is crucial to the success of BDD to focus on what value a feature provides to the business. Always understand the the role of the user and their relationship to the feature. Do not get distracted by the technical aspects of the implementation.
  • 14. Writing Features Applications are comprised of features BDD discretely separates each feature Each feature contains a narrative and a scenario Feature may also contain a background to set the stage for the feature scenarios
  • 15. Narrative Feature narratives are written similarly to Agile/Scrum stories and must answer these questions: What is the business benefit? Who is the beneficiary? What is the action performed?
  • 16. Background A background should contain steps common to all, or at least most, scenarios to prepare the application environment for the scenarios. Background steps should be tested elsewhere as part of another feature. Steps failing in the background steps will identify that the failure is not related to the feature.
  • 17. Scenario A scenarios should contain a narrative Scenarios work in a manner similar to unit tests by arranging the environment necessary to begin the test, perform actions, and then assert that the expected results have been attained Scenarios should not test multiple features. Do not perform actions after assertions.
  • 18. Scenario Outline Scenario outlines use a common set of steps with placeholders for data provided in a data table. They are a replacement for multiple scenarios in which data is the only differentiator and does not define the feature. Adding sales tax would be an example of a feature in which the data in the action and assertion would be different.
  • 19. Step Steps do one of the following: Arrange the environment Perform an action Assert a result of the previous actions Steps should be reasonably reusable Steps should be aggregated for simplification when arranging the environment
  • 20.
  • 21. What is Behat? Open source Behavior Driven Development framework for PHP Official PHP implementation of Cucumber One of the easiest Cucumber implementations to get up and running quickly Good documentation: http://docs.behat.org
  • 22. Installation PHAR installation Single global install One version for feature contexts Project Installation Composer based install as dependency Version and dependencies tied to project
  • 23. Components Command line executable – behat Configuration file – behat.yml Feature context(s) Feature Files
  • 24. Command Line Executable Allows for initializing the environment Running features Features and scenarios filterable by tags Chooses environment Listing step definitions
  • 25. Configuration File Split up into profiles (inherit from default) Configures custom autoloader path Defines global tag filters Defines output formatters Defines feature suites Configures extensions
  • 26. Feature Context Defines steps May extend other contexts May access other contexts May add hooks for pre/post tag, step, scenario, feature, and suite execution.
  • 27. Gherkin Gherkin is a Domain Specific Language (DSL) utilized to write Features in Behat. It uses key words to identify the type of step: Given – Arrange When – Act Then - Assert
  • 28. Example Gherkin Feature: Home Page Scenario: Login Link Given I am on the homepage When I click " Login" Then I will be on the "LaunchKey | Log in" page
  • 29. Step Backing Code Method on a feature context Contains doc block annotated (@) matchers Support defined in context. Defaults to Turnip Supports Turnip and regular expressions Can contain examples doc block Can contain descript in the doc block
  • 30. Example Step /** * Opens homepage * Example: Given I am on "/" * Example: When I go to "/" * Example: And I go to "/” * @Given (I )am on :path * @When (I )go to :path */ public function visitPath($path) { $this->browser->open($path); }
  • 31.
  • 32. Create a Project Composer “init” Add requirements Behat “init” Add Contexts to Config
  • 33. Verify Your Install Run “vendor/bin/behat –h” You should see the help text
  • 34. Initialize Behat Initialize the behat project via the Behat CLI with the --init flag Verify by running “vendor/bin/behat”
  • 35. Add Mink to Config • Add the extension to the default profile • Set the base URL • Add the drivers
  • 36. Add Contexts to Config • Add Mink context to get access to pre-built browser steps • Add project context to make custom steps
  • 37. Verify Configuration Run “vendor/bin/behat –dl” You should see a LOT of steps Run “vendor/bin/behat –di” You should see additional information for the steps
  • 38. Lets Write A Feature Test User Story: In order to use the site As a site visitor I can access the website
  • 39. Let’s Make Another Requirement: In order to be a user As a visitor I can register for a user account
  • 40. What About Clean Up Requirement: E-Mail Address is the user identifier and must be unique among all users We’re going to have to clean up users in a hook
  • 41. Steps Need to Be Intuitive Checking for errors on registration submission will require a custom step with some additional logic
  • 42. Add Other Requirements E-Mail Address is the user identifier and must be unique among all users Name is required and captures the users name Password is required and must utilize a verification field to ensure correct password entry
  • 43. Finish Up Labs/Examples Server and Behat features found in GitHub: https://github.com/aenglander/bdd-with-behat-for- beginners Master branch is Behat Master is tagged to go step by step Server branch is server
  • 44. Selenium Industry standard Server with remote API Direct integration with Behat/Mink via Selenium Driver Can be used headless with PhantomJS via GhostDriver implementation
  • 45. Using Selenium Server Add config to bahat.yml and specify browser Apply @javascript tag to scenarios or a feature Start Selenium Standalone Server Run tests
  • 46. Selenium Grid Allows for multiple simultaneous test runs, multiple browser versions, and multiple operating systems One Hub and Multiple Nodes Uses same app as Standalone Server Can be flakey and hard to manage
  • 47. Sauce Labs/BrowserStack Special Drivers for Sauce Labs and BrowserStack Not well documented but work very well Allow for a “Grid” style environment without managing the Grid
  • 48. Configuring Mink Driver Poorly documented Easy to figure out the settings by looking at the driver factories. See: vendor/behat/mink- extension/src/Behat/MinkExtension/ServiceContainer /Driver
  • 49. Best Practices Feature files contain one Feature Features should be more business than technical focused
  • 50. Best Practices (cont.) Use the three A’s Arrange – Background – Given Act – When Assert - Then
  • 51. Best Practices (cont.) Make steps visually verifiable. Feature files should be able to serve as documentation Clean up after yourself Scenarios should be idempotent Spend the time to do it the right way

Editor's Notes

  1. Extensions are usually pre-enabled by default with Linux or Mac package managers. Windows users need to uncomment the line n the php.ini. Search for “date.timezone”. Set it to whatever you like. If you are not sure you can use “UTC”.
  2. The direct correlation between the SOAP box and BDD is the reason BDD is becoming more and more popular.
  3. I never meant to learn BDD. I was just looking for a tool to help me stop breaking a critical legacy business application every time we released a new feature. We had built entire integration testing platforms but they would not give me or the business what we needed to identify defects and were constantly giving false positives and negatives to the brittle nature of the tests. The first step was using feature based testing with Cucumber and then Behat when it became available. Embracing BDD, like everything else in my career, was a process of enlightenment. It took time and required pain to drive growth.
  4. composer init composer require --dev behat/behat behat/mink-extension behat/mink-goutte-driver behat/mink-selenium2-driver vendor/bin/behat --init vendor/bin/behat -h
  5. vendor/bin/behat --init vendor/bin/behat
  6. default: extensions: Behat\MinkExtension: base_url: http://adam-bdd-with-behat.ngrok.io goutte: ~ selenium2: ~
  7. default: suites: default: contexts: - Behat\MinkExtension\Context\MinkContext - FeatureContext
  8. Vendor/bin/behat -dl
  9. Feature: A visitor can access the homepage In order to use the site As a site visitor I can access the website Scenario: Homepage loads When I go to the homepage Then I should see "Your Application's Landing Page. "
  10. Feature: User Registration In order to be a user As a visitor I can register for a user account Background: Given I am on "/register" Scenario: Proper fields register the user When I fill in the following: | Name | Adam | | E-Mail Address | test.email@launchkey.com | | Password | Password1 | | Confirm Password | Password1 | And I press "Register" Then I should be on the homepage And the response should contain "Logout"
  11. use Behat\Behat\Hook\Scope\BeforeScenarioScope; /** * @BeforeScenario */ public function cleanupUsers(BeforeScenarioScope $scope) { $this->mink = $scope->getEnvironment()->getContext('Behat\MinkExtension\Context\MinkContext'); $this->mink->visit(‘/delete-test-users’); }
  12. /** * @Then the :field field should have an error */ public function theFieldHasAnError($field) { $has = $this->mink->getSession() ->getPage() ->findField($field) ->getParent() ->has('css', 'span.help-block'); if ( ! $has) { throw new \Exception("Field \"{$field}\" has no error"); } }
  13. Behat\MinkExtension: browser_name: chrome goutte: ~ selenium2: ~