SlideShare une entreprise Scribd logo
1  sur  66
BDD, Behat, & Drupal 
by Bozhidar Boshnakov
About me 
• Bozhidar Boshnakov 
• Team leader @ ProPeople 
• bboshnakov91@gmail.com 
• Skype: bo6nakov 
• Drupal.org – bboshnakov 
• linkedin.com/in/bboshnakov
Table of contents 
• What is Behavior-Driven Development? 
• Why Behavior-Driven Development? 
• How to BDD? 
• How to automate BDD? 
• How to do it in Drupal?
INTELLIGENCE 
IS 
A LIABILITY!
SMART PEOPLE 
Can make progress … 
… without process 
This is not a good thing !!!
Professionals 
• Design, plan and prepare first 
• …then do the work 
• This produces better results FASTER !!!
Process is the difference 
between 
Software 
Engineering &Programming
Test-Driven Development 
…is an iterative design process 
• Write a test 
• Ensure the new test fails 
• Write code to satisfy the test 
• Ensure all tests pass 
• Refactor 
• Repeat
“BDD is about implementing an 
application by describing its 
behavior from the perspective of 
its stakeholders.” 
Dan North
Behavior-Driven Development 
…builds upon TDD 
• Write test cases in a natural language 
– Understood by developers and business folks alike 
– Helps relate domain language of requirements to 
the code 
• Do this with user stories and scenarios 
– User stories describe a feature’s benefit in context 
– Scenarios are executable acceptance criteria
START TALKING 
Using the language business can understand
“When browsing an article 
user should be able to see 
related articles”
Start asking 
• Why would anyone want this feature? 
• Who will use this feature? 
• What does he/she need to use it?
Story narrative 
In order to have that cool feature everyone else has
Story narrative 
In order to read more interesting articles 
As a user
Story narrative 
In order to read more interesting articles 
As a reader 
I need to see related articles to the one I’m reading
Story narrative 
In order to read more interesting articles 
As a reader 
I need to see related articles to the one I’m reading
Stories 
In order to read more interesting articles 
As a reader 
I need to see related articles to the one I’m reading 
In order to find most interesting articles faster 
As a reader 
I need to be presented with high-rating articles first 
In order to always provide high-quality content 
As a moderator 
I need to be able to review articles before publishing 
In order to protect reads from spam 
As an administrator 
I need to differentiate humans from robots
Stories 
In order to read more interesting articles 
As a reader 
I need to see related articles to the one I’m reading 
In order to find most interesting articles faster 
As a reader 
I need to be presented with high-rating articles first 
In order to always provide high-quality content 
As a moderator 
I need to be able to review articles before publishing 
In order to protect reads from spam 
As an administrator 
I need to differentiate humans from robots 
1 
4 
3 
2
Tips & tricks 
“Can you give me an example?” 
“Is there a case in which this example wouldn’t be true?” 
“Is that the only outcome?” 
“Does the user has full control?”
Feature 
Feature: Related articles 
in order to read more interesting articles 
as a reader 
I need to see related articles to the one I’m reading 
Scenario: Seeing an article with the same word in the title 
Given there is a “DrupalCamp is awesome” article 
And there is a “DrupalCamp sessions” article 
When I read the “DrupalCamp is awesome” article 
Then the “DrupalCamp sessions” should be in the list of related articles 
Scenario: Seeing an article with same tag 
Given there is a “DrupalCamp is awesome” article tagged “DrupalCampSofia2014” 
And there is a “Drupal 8 is great” article tagged “DrupalCampSofia2014” 
When I read the “DrupalCamp is awesome” article 
Then the “Drupal 8 is great” should be in the list of related articles
Gherkin 
Gherkin is a Business Readable, Domain 
Specific Language created especially for 
behavior descriptions. It gives you the 
ability to remove logic details from 
behavior tests.
Gherkin Syntax
Gherkin Syntax 
Feature: Banana Calculator 
As Bob the Banana merchant, 
I want a calculator that can add the amount of 
bananas so that I can know how many bananas I 
currently have 
Scenario: Will add 2 banana amounts 
Given I have 3 Bananas 
When I add 5 Bananas 
Then I should have 8 Banana
In order to verify application behavior 
As a software developer 
I need tests 
Preferably automated tests
This is where 
and come in
Behat is an open source behavior-driven 
development framework for 
PHP 5.3 and 5.4. 
Created by Konstantin Kudryashov
Before you begin, ensure that you have at least PHP 5.3.1 installed. 
The simplest way to 
install Behat is through 
Composer.
Composer.json 
{ 
"require": { 
"behat/mink": "*", 
"behat/mink-goutte-driver": "*", 
"behat/behat": "*", 
"behat/mink-extension": "*", 
"drupal/drupal-extension": "*" 
}, 
"minimum-stability": "dev", 
"config": { 
"bin-dir": "bin/" 
} 
}
Composer.phar 
Then download composer.phar and run install 
command: 
$ curl http://getcomposer.org/installer | php 
$ php composer.phar install
Behat.yml 
default: 
extensions: 
BehatMinkExtensionExtension: 
base_url: http://wearepropeople.com 
goutte: ~ 
selenium2: ~ 
paths: 
features: features 
bootstrap: features/bootstrap
And the last step… 
php bin/behat --init 
And now you have your Features folder 
where you can create the magic!!!
What are the features?
Let's Have Behat Analyze Our Feature
Behat Creates the Glue 
...but the rest is up to you
Not so fast. What about Mink?
Understanding Mink 
One of the most important parts in the 
web is a browser. A browser is the window 
through which web application users 
interact with the application and other 
users.
Headless 
browser 
emulators VS Browser 
controllers
Selenium2Driver 
• Control the Browser – Session 
• Cookies and Headers management 
• HTTP Authentication 
• Traverse the Page - Selectors 
• Manipulate the Page
Mink Context Defines Steps 
...for making requests
Mink Context Defines Steps 
...for interacting with forms
Mink Context Defines Steps 
...for querying the DOM
Mink Context Defines Steps 
...for examining responses
Now… 
Let’s get away from the 
theory and show some 
action!
Tags 
Tags are a great way to organize your 
features and scenarios: 
A Scenario or Feature can have as many 
tags as you like, just separate them with 
spaces:
Tags 
How to execute the tags? 
If a tag exists on a Feature, Behat 
will assign that tag to all child 
Scenarios and Scenario Outlines 
too!
Behat.yml 
All configuration happens inside a 
single configuration file in the 
YAML format.
Imports 
…or share your feature configurations
Profiles 
$bin/behat –p google features/feature1
The Drupal extension 
• Overrides default behaviors: 
– Snippets follow Drupal coding standards 
– Mink Extension steps get synonyms for readability 
• Provides drivers to facilitate data setup 
– Blackbox 
– Drush 
– Drupal API 
• Adds support for Drupal: 
– Regions 
– Node types 
– Users and Roles 
– Taxonomy 
– Subcontexts for Contributed Modules
Provides drivers for data set up 
• Works with Drupal 6, 7, and 8 
• Connect with no privileges (local or remote) 
• Connect with Drush (local or remote) 
• Connect with the Drupal API (local only)
Drush: alias file 
http://drush.ws/examples/example.aliases.drushrc.php
Drush: behat.yml
Drupal API: behat.yml
Region map: behat.yml
Regions 
Requires a map in the behat.yml file 
• label => css selector 
• This means regions don’t have to map directly to 
Drupal theme regions
Structure > Blocks > (Theme) > Demonstrate block regions
Nodes
Users, roles and taxonomies
Relational data
Relational data
If you have any questions or you want 
access for the full installation guideline feel 
free to contact me on my email address: 
bboshnakov91@gmail.com
Resources 
• http://dspeak.com/pnwds/6-drupalextension.html 
• http://docs.behat.org/guides/7.config.html 
• http://behat.org/ 
• http://mink.behat.org/ 
• https://amsterdam2014.drupal.org/session/doing-behaviour- 
driven-development-behat
Thank you!!!
BDD, Behat & Drupal

Contenu connexe

Tendances

Django for Beginners
Django for BeginnersDjango for Beginners
Django for BeginnersJason Davies
 
BDD to the Bone: Using Behave and Selenium to Test-Drive Web Applications
BDD to the Bone: Using Behave and Selenium to Test-Drive Web ApplicationsBDD to the Bone: Using Behave and Selenium to Test-Drive Web Applications
BDD to the Bone: Using Behave and Selenium to Test-Drive Web ApplicationsPatrick Viafore
 
Implementing Testing for Behavior-Driven Development Using Cucumber
Implementing Testing for Behavior-Driven Development Using CucumberImplementing Testing for Behavior-Driven Development Using Cucumber
Implementing Testing for Behavior-Driven Development Using CucumberTechWell
 
Legacy: A Retrospective - Open West 2016
Legacy: A Retrospective - Open West 2016Legacy: A Retrospective - Open West 2016
Legacy: A Retrospective - Open West 2016Jessica Mauerhan
 
A Universal Automation Framework based on BDD Cucumber and Ruby on Rails - Ph...
A Universal Automation Framework based on BDD Cucumber and Ruby on Rails - Ph...A Universal Automation Framework based on BDD Cucumber and Ruby on Rails - Ph...
A Universal Automation Framework based on BDD Cucumber and Ruby on Rails - Ph...Ho Chi Minh City Software Testing Club
 
Lunch and learn: Cucumber and Capybara
Lunch and learn: Cucumber and CapybaraLunch and learn: Cucumber and Capybara
Lunch and learn: Cucumber and CapybaraMarc Seeger
 
Behavior Driven Web UI Automation with Selenium and Cucumber/SpecFlow (BDDx L...
Behavior Driven Web UI Automation with Selenium and Cucumber/SpecFlow (BDDx L...Behavior Driven Web UI Automation with Selenium and Cucumber/SpecFlow (BDDx L...
Behavior Driven Web UI Automation with Selenium and Cucumber/SpecFlow (BDDx L...Gáspár Nagy
 
Writing automation tests with python selenium behave pageobjects
Writing automation tests with python selenium behave pageobjectsWriting automation tests with python selenium behave pageobjects
Writing automation tests with python selenium behave pageobjectsLeticia Rss
 
Selenium and Cucumber Selenium Conf 2011
Selenium and Cucumber Selenium Conf 2011Selenium and Cucumber Selenium Conf 2011
Selenium and Cucumber Selenium Conf 2011dimakovalenko
 
Behat - Drupal South 2018
Behat  - Drupal South 2018Behat  - Drupal South 2018
Behat - Drupal South 2018Berend de Boer
 
[Thong Nguyen & Trong Bui] Behavior Driven Development (BDD) and Automation T...
[Thong Nguyen & Trong Bui] Behavior Driven Development (BDD) and Automation T...[Thong Nguyen & Trong Bui] Behavior Driven Development (BDD) and Automation T...
[Thong Nguyen & Trong Bui] Behavior Driven Development (BDD) and Automation T...Ho Chi Minh City Software Testing Club
 
Getting Started with Test Automation: Introduction to Cucumber with Lapis Lazuli
Getting Started with Test Automation: Introduction to Cucumber with Lapis LazuliGetting Started with Test Automation: Introduction to Cucumber with Lapis Lazuli
Getting Started with Test Automation: Introduction to Cucumber with Lapis LazuliRebecca Eloise Hogg
 
Django Introduction & Tutorial
Django Introduction & TutorialDjango Introduction & Tutorial
Django Introduction & Tutorial之宇 趙
 
An easy guide to Plugin Development
An easy guide to Plugin DevelopmentAn easy guide to Plugin Development
An easy guide to Plugin DevelopmentShinichi Nishikawa
 
Ruby onrails cucumber-rspec-capybara
Ruby onrails cucumber-rspec-capybaraRuby onrails cucumber-rspec-capybara
Ruby onrails cucumber-rspec-capybaraBindesh Vijayan
 
API Technical Writing
API Technical WritingAPI Technical Writing
API Technical WritingSarah Maddox
 
BDD / cucumber /Capybara
BDD / cucumber /CapybaraBDD / cucumber /Capybara
BDD / cucumber /CapybaraShraddhaSF
 
Geb for testing your grails application
Geb for testing your grails applicationGeb for testing your grails application
Geb for testing your grails applicationJacobAae
 

Tendances (20)

Django for Beginners
Django for BeginnersDjango for Beginners
Django for Beginners
 
BDD to the Bone: Using Behave and Selenium to Test-Drive Web Applications
BDD to the Bone: Using Behave and Selenium to Test-Drive Web ApplicationsBDD to the Bone: Using Behave and Selenium to Test-Drive Web Applications
BDD to the Bone: Using Behave and Selenium to Test-Drive Web Applications
 
Implementing Testing for Behavior-Driven Development Using Cucumber
Implementing Testing for Behavior-Driven Development Using CucumberImplementing Testing for Behavior-Driven Development Using Cucumber
Implementing Testing for Behavior-Driven Development Using Cucumber
 
Legacy: A Retrospective - Open West 2016
Legacy: A Retrospective - Open West 2016Legacy: A Retrospective - Open West 2016
Legacy: A Retrospective - Open West 2016
 
A Universal Automation Framework based on BDD Cucumber and Ruby on Rails - Ph...
A Universal Automation Framework based on BDD Cucumber and Ruby on Rails - Ph...A Universal Automation Framework based on BDD Cucumber and Ruby on Rails - Ph...
A Universal Automation Framework based on BDD Cucumber and Ruby on Rails - Ph...
 
Lunch and learn: Cucumber and Capybara
Lunch and learn: Cucumber and CapybaraLunch and learn: Cucumber and Capybara
Lunch and learn: Cucumber and Capybara
 
Behavior Driven Web UI Automation with Selenium and Cucumber/SpecFlow (BDDx L...
Behavior Driven Web UI Automation with Selenium and Cucumber/SpecFlow (BDDx L...Behavior Driven Web UI Automation with Selenium and Cucumber/SpecFlow (BDDx L...
Behavior Driven Web UI Automation with Selenium and Cucumber/SpecFlow (BDDx L...
 
Writing automation tests with python selenium behave pageobjects
Writing automation tests with python selenium behave pageobjectsWriting automation tests with python selenium behave pageobjects
Writing automation tests with python selenium behave pageobjects
 
Selenium and Cucumber Selenium Conf 2011
Selenium and Cucumber Selenium Conf 2011Selenium and Cucumber Selenium Conf 2011
Selenium and Cucumber Selenium Conf 2011
 
Django Best Practices
Django Best PracticesDjango Best Practices
Django Best Practices
 
Behat - Drupal South 2018
Behat  - Drupal South 2018Behat  - Drupal South 2018
Behat - Drupal South 2018
 
[Thong Nguyen & Trong Bui] Behavior Driven Development (BDD) and Automation T...
[Thong Nguyen & Trong Bui] Behavior Driven Development (BDD) and Automation T...[Thong Nguyen & Trong Bui] Behavior Driven Development (BDD) and Automation T...
[Thong Nguyen & Trong Bui] Behavior Driven Development (BDD) and Automation T...
 
Getting Started with Test Automation: Introduction to Cucumber with Lapis Lazuli
Getting Started with Test Automation: Introduction to Cucumber with Lapis LazuliGetting Started with Test Automation: Introduction to Cucumber with Lapis Lazuli
Getting Started with Test Automation: Introduction to Cucumber with Lapis Lazuli
 
Django Girls Tutorial
Django Girls TutorialDjango Girls Tutorial
Django Girls Tutorial
 
Django Introduction & Tutorial
Django Introduction & TutorialDjango Introduction & Tutorial
Django Introduction & Tutorial
 
An easy guide to Plugin Development
An easy guide to Plugin DevelopmentAn easy guide to Plugin Development
An easy guide to Plugin Development
 
Ruby onrails cucumber-rspec-capybara
Ruby onrails cucumber-rspec-capybaraRuby onrails cucumber-rspec-capybara
Ruby onrails cucumber-rspec-capybara
 
API Technical Writing
API Technical WritingAPI Technical Writing
API Technical Writing
 
BDD / cucumber /Capybara
BDD / cucumber /CapybaraBDD / cucumber /Capybara
BDD / cucumber /Capybara
 
Geb for testing your grails application
Geb for testing your grails applicationGeb for testing your grails application
Geb for testing your grails application
 

Similaire à BDD, Behat & Drupal

BathCamp #32 - CMS Smackdown! - Plone
BathCamp #32 - CMS Smackdown! - PloneBathCamp #32 - CMS Smackdown! - Plone
BathCamp #32 - CMS Smackdown! - PloneMatt Hamilton
 
[drupalday2017] - Behat per Drupal: test automatici e molto di più
[drupalday2017] - Behat per Drupal: test automatici e molto di più[drupalday2017] - Behat per Drupal: test automatici e molto di più
[drupalday2017] - Behat per Drupal: test automatici e molto di piùDrupalDay
 
Behaviour Driven Development
Behaviour Driven DevelopmentBehaviour Driven Development
Behaviour Driven DevelopmentAndy Kelk
 
Rapidly prototyping web applications using BackPress
Rapidly prototyping web applications using BackPressRapidly prototyping web applications using BackPress
Rapidly prototyping web applications using BackPressNathaniel Taintor
 
Open event (show&tell april 2016)
Open event (show&tell april 2016)Open event (show&tell april 2016)
Open event (show&tell april 2016)Jorge López-Lago
 
Behat - human-readable automated testing
Behat - human-readable automated testingBehat - human-readable automated testing
Behat - human-readable automated testingnyccamp
 
Frontend for developers
Frontend for developersFrontend for developers
Frontend for developersHernan Mammana
 
Functional testing with behat
Functional testing with behatFunctional testing with behat
Functional testing with behatTahmina Khatoon
 
Managing a Project the Drupal Way - Drupal Open Days Ireland
Managing a Project the Drupal Way - Drupal Open Days IrelandManaging a Project the Drupal Way - Drupal Open Days Ireland
Managing a Project the Drupal Way - Drupal Open Days IrelandEmma Jane Hogbin Westby
 
If you want to automate, you learn to code
If you want to automate, you learn to codeIf you want to automate, you learn to code
If you want to automate, you learn to codeAlan Richardson
 
WordCamp Asheville 2017 - So You Wanna Dev? Join the Team!
WordCamp Asheville 2017 - So You Wanna Dev? Join the Team!WordCamp Asheville 2017 - So You Wanna Dev? Join the Team!
WordCamp Asheville 2017 - So You Wanna Dev? Join the Team!Evan Mullins
 
Getting Started with Drupal
Getting Started with DrupalGetting Started with Drupal
Getting Started with DrupalRachel Vacek
 
Publishing strategies for API documentation
Publishing strategies for API documentationPublishing strategies for API documentation
Publishing strategies for API documentationTom Johnson
 
WordCamp Greenville 2018 - Beware the Dark Side, or an Intro to Development
WordCamp Greenville 2018 - Beware the Dark Side, or an Intro to DevelopmentWordCamp Greenville 2018 - Beware the Dark Side, or an Intro to Development
WordCamp Greenville 2018 - Beware the Dark Side, or an Intro to DevelopmentEvan Mullins
 
Grand Rapids PHP Meetup: Behavioral Driven Development with Behat
Grand Rapids PHP Meetup: Behavioral Driven Development with BehatGrand Rapids PHP Meetup: Behavioral Driven Development with Behat
Grand Rapids PHP Meetup: Behavioral Driven Development with BehatRyan Weaver
 

Similaire à BDD, Behat & Drupal (20)

Automation in Drupal
Automation in DrupalAutomation in Drupal
Automation in Drupal
 
BathCamp #32 - CMS Smackdown! - Plone
BathCamp #32 - CMS Smackdown! - PloneBathCamp #32 - CMS Smackdown! - Plone
BathCamp #32 - CMS Smackdown! - Plone
 
[drupalday2017] - Behat per Drupal: test automatici e molto di più
[drupalday2017] - Behat per Drupal: test automatici e molto di più[drupalday2017] - Behat per Drupal: test automatici e molto di più
[drupalday2017] - Behat per Drupal: test automatici e molto di più
 
Behaviour Driven Development
Behaviour Driven DevelopmentBehaviour Driven Development
Behaviour Driven Development
 
Rapidly prototyping web applications using BackPress
Rapidly prototyping web applications using BackPressRapidly prototyping web applications using BackPress
Rapidly prototyping web applications using BackPress
 
Open event (show&tell april 2016)
Open event (show&tell april 2016)Open event (show&tell april 2016)
Open event (show&tell april 2016)
 
Joomla tempates talk
Joomla tempates talkJoomla tempates talk
Joomla tempates talk
 
Introduce Django
Introduce DjangoIntroduce Django
Introduce Django
 
Behat - human-readable automated testing
Behat - human-readable automated testingBehat - human-readable automated testing
Behat - human-readable automated testing
 
Frontend for developers
Frontend for developersFrontend for developers
Frontend for developers
 
Functional testing with behat
Functional testing with behatFunctional testing with behat
Functional testing with behat
 
Managing a Project the Drupal Way - Drupal Open Days Ireland
Managing a Project the Drupal Way - Drupal Open Days IrelandManaging a Project the Drupal Way - Drupal Open Days Ireland
Managing a Project the Drupal Way - Drupal Open Days Ireland
 
If you want to automate, you learn to code
If you want to automate, you learn to codeIf you want to automate, you learn to code
If you want to automate, you learn to code
 
Wp 3hr-course
Wp 3hr-courseWp 3hr-course
Wp 3hr-course
 
WordCamp Asheville 2017 - So You Wanna Dev? Join the Team!
WordCamp Asheville 2017 - So You Wanna Dev? Join the Team!WordCamp Asheville 2017 - So You Wanna Dev? Join the Team!
WordCamp Asheville 2017 - So You Wanna Dev? Join the Team!
 
Getting Started with Drupal
Getting Started with DrupalGetting Started with Drupal
Getting Started with Drupal
 
Publishing strategies for API documentation
Publishing strategies for API documentationPublishing strategies for API documentation
Publishing strategies for API documentation
 
WordCamp Greenville 2018 - Beware the Dark Side, or an Intro to Development
WordCamp Greenville 2018 - Beware the Dark Side, or an Intro to DevelopmentWordCamp Greenville 2018 - Beware the Dark Side, or an Intro to Development
WordCamp Greenville 2018 - Beware the Dark Side, or an Intro to Development
 
Grand Rapids PHP Meetup: Behavioral Driven Development with Behat
Grand Rapids PHP Meetup: Behavioral Driven Development with BehatGrand Rapids PHP Meetup: Behavioral Driven Development with Behat
Grand Rapids PHP Meetup: Behavioral Driven Development with Behat
 
Django
DjangoDjango
Django
 

Plus de Bozhidar Boshnakov

Object-Oriented Programming with PHP (part 1)
Object-Oriented Programming with PHP (part 1)Object-Oriented Programming with PHP (part 1)
Object-Oriented Programming with PHP (part 1)Bozhidar Boshnakov
 
PMG Gabrovo - Web Development Level 0 - Introduction
PMG Gabrovo - Web Development Level 0 - IntroductionPMG Gabrovo - Web Development Level 0 - Introduction
PMG Gabrovo - Web Development Level 0 - IntroductionBozhidar Boshnakov
 
QA Challange Accepted - How and why we should use Behat?
QA Challange Accepted - How and why we should use Behat?QA Challange Accepted - How and why we should use Behat?
QA Challange Accepted - How and why we should use Behat?Bozhidar Boshnakov
 
Как да направим живота си по - лесен с добър QA подход
Как да направим живота си по - лесен с добър QA подходКак да направим живота си по - лесен с добър QA подход
Как да направим живота си по - лесен с добър QA подходBozhidar Boshnakov
 

Plus de Bozhidar Boshnakov (10)

Mission possible - revival
Mission possible - revivalMission possible - revival
Mission possible - revival
 
Object-Oriented Programming with PHP (part 1)
Object-Oriented Programming with PHP (part 1)Object-Oriented Programming with PHP (part 1)
Object-Oriented Programming with PHP (part 1)
 
Introduction in php part 2
Introduction in php part 2Introduction in php part 2
Introduction in php part 2
 
Introduction in php
Introduction in phpIntroduction in php
Introduction in php
 
Web fundamentals 2
Web fundamentals 2Web fundamentals 2
Web fundamentals 2
 
Web fundamentals - part 1
Web fundamentals - part 1Web fundamentals - part 1
Web fundamentals - part 1
 
PMG Gabrovo - Web Development Level 0 - Introduction
PMG Gabrovo - Web Development Level 0 - IntroductionPMG Gabrovo - Web Development Level 0 - Introduction
PMG Gabrovo - Web Development Level 0 - Introduction
 
QA Challange Accepted - How and why we should use Behat?
QA Challange Accepted - How and why we should use Behat?QA Challange Accepted - How and why we should use Behat?
QA Challange Accepted - How and why we should use Behat?
 
DrupalCamp Sofia 2015
DrupalCamp Sofia 2015DrupalCamp Sofia 2015
DrupalCamp Sofia 2015
 
Как да направим живота си по - лесен с добър QA подход
Как да направим живота си по - лесен с добър QA подходКак да направим живота си по - лесен с добър QA подход
Как да направим живота си по - лесен с добър QA подход
 

Dernier

Introduction to Firebase Workshop Slides
Introduction to Firebase Workshop SlidesIntroduction to Firebase Workshop Slides
Introduction to Firebase Workshop Slidesvaideheekore1
 
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...Bert Jan Schrijver
 
Large Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLarge Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLionel Briand
 
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptxReal-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptxRTS corp
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfDrew Moseley
 
Zer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdfZer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdfmaor17
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalLionel Briand
 
Osi security architecture in network.pptx
Osi security architecture in network.pptxOsi security architecture in network.pptx
Osi security architecture in network.pptxVinzoCenzo
 
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...OnePlan Solutions
 
Effectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryErrorEffectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryErrorTier1 app
 
What’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesWhat’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesVictoriaMetrics
 
2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shards2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shardsChristopher Curtin
 
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptxThe Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptxRTS corp
 
Ronisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited CatalogueRonisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited Catalogueitservices996
 
eSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration toolseSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration toolsosttopstonverter
 
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4j
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4jGraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4j
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4jNeo4j
 
VictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News UpdateVictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News UpdateVictoriaMetrics
 
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdfAndrey Devyatkin
 
Post Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on IdentityPost Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on Identityteam-WIBU
 
Leveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + KobitonLeveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + KobitonApplitools
 

Dernier (20)

Introduction to Firebase Workshop Slides
Introduction to Firebase Workshop SlidesIntroduction to Firebase Workshop Slides
Introduction to Firebase Workshop Slides
 
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
 
Large Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLarge Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and Repair
 
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptxReal-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdf
 
Zer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdfZer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdf
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive Goal
 
Osi security architecture in network.pptx
Osi security architecture in network.pptxOsi security architecture in network.pptx
Osi security architecture in network.pptx
 
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
 
Effectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryErrorEffectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryError
 
What’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesWhat’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 Updates
 
2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shards2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shards
 
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptxThe Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
 
Ronisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited CatalogueRonisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited Catalogue
 
eSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration toolseSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration tools
 
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4j
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4jGraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4j
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4j
 
VictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News UpdateVictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News Update
 
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
 
Post Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on IdentityPost Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on Identity
 
Leveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + KobitonLeveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
 

BDD, Behat & Drupal

  • 1. BDD, Behat, & Drupal by Bozhidar Boshnakov
  • 2. About me • Bozhidar Boshnakov • Team leader @ ProPeople • bboshnakov91@gmail.com • Skype: bo6nakov • Drupal.org – bboshnakov • linkedin.com/in/bboshnakov
  • 3. Table of contents • What is Behavior-Driven Development? • Why Behavior-Driven Development? • How to BDD? • How to automate BDD? • How to do it in Drupal?
  • 4. INTELLIGENCE IS A LIABILITY!
  • 5. SMART PEOPLE Can make progress … … without process This is not a good thing !!!
  • 6. Professionals • Design, plan and prepare first • …then do the work • This produces better results FASTER !!!
  • 7. Process is the difference between Software Engineering &Programming
  • 8. Test-Driven Development …is an iterative design process • Write a test • Ensure the new test fails • Write code to satisfy the test • Ensure all tests pass • Refactor • Repeat
  • 9. “BDD is about implementing an application by describing its behavior from the perspective of its stakeholders.” Dan North
  • 10. Behavior-Driven Development …builds upon TDD • Write test cases in a natural language – Understood by developers and business folks alike – Helps relate domain language of requirements to the code • Do this with user stories and scenarios – User stories describe a feature’s benefit in context – Scenarios are executable acceptance criteria
  • 11. START TALKING Using the language business can understand
  • 12. “When browsing an article user should be able to see related articles”
  • 13. Start asking • Why would anyone want this feature? • Who will use this feature? • What does he/she need to use it?
  • 14. Story narrative In order to have that cool feature everyone else has
  • 15. Story narrative In order to read more interesting articles As a user
  • 16. Story narrative In order to read more interesting articles As a reader I need to see related articles to the one I’m reading
  • 17. Story narrative In order to read more interesting articles As a reader I need to see related articles to the one I’m reading
  • 18. Stories In order to read more interesting articles As a reader I need to see related articles to the one I’m reading In order to find most interesting articles faster As a reader I need to be presented with high-rating articles first In order to always provide high-quality content As a moderator I need to be able to review articles before publishing In order to protect reads from spam As an administrator I need to differentiate humans from robots
  • 19. Stories In order to read more interesting articles As a reader I need to see related articles to the one I’m reading In order to find most interesting articles faster As a reader I need to be presented with high-rating articles first In order to always provide high-quality content As a moderator I need to be able to review articles before publishing In order to protect reads from spam As an administrator I need to differentiate humans from robots 1 4 3 2
  • 20. Tips & tricks “Can you give me an example?” “Is there a case in which this example wouldn’t be true?” “Is that the only outcome?” “Does the user has full control?”
  • 21. Feature Feature: Related articles in order to read more interesting articles as a reader I need to see related articles to the one I’m reading Scenario: Seeing an article with the same word in the title Given there is a “DrupalCamp is awesome” article And there is a “DrupalCamp sessions” article When I read the “DrupalCamp is awesome” article Then the “DrupalCamp sessions” should be in the list of related articles Scenario: Seeing an article with same tag Given there is a “DrupalCamp is awesome” article tagged “DrupalCampSofia2014” And there is a “Drupal 8 is great” article tagged “DrupalCampSofia2014” When I read the “DrupalCamp is awesome” article Then the “Drupal 8 is great” should be in the list of related articles
  • 22. Gherkin Gherkin is a Business Readable, Domain Specific Language created especially for behavior descriptions. It gives you the ability to remove logic details from behavior tests.
  • 24. Gherkin Syntax Feature: Banana Calculator As Bob the Banana merchant, I want a calculator that can add the amount of bananas so that I can know how many bananas I currently have Scenario: Will add 2 banana amounts Given I have 3 Bananas When I add 5 Bananas Then I should have 8 Banana
  • 25.
  • 26. In order to verify application behavior As a software developer I need tests Preferably automated tests
  • 27. This is where and come in
  • 28. Behat is an open source behavior-driven development framework for PHP 5.3 and 5.4. Created by Konstantin Kudryashov
  • 29. Before you begin, ensure that you have at least PHP 5.3.1 installed. The simplest way to install Behat is through Composer.
  • 30. Composer.json { "require": { "behat/mink": "*", "behat/mink-goutte-driver": "*", "behat/behat": "*", "behat/mink-extension": "*", "drupal/drupal-extension": "*" }, "minimum-stability": "dev", "config": { "bin-dir": "bin/" } }
  • 31. Composer.phar Then download composer.phar and run install command: $ curl http://getcomposer.org/installer | php $ php composer.phar install
  • 32. Behat.yml default: extensions: BehatMinkExtensionExtension: base_url: http://wearepropeople.com goutte: ~ selenium2: ~ paths: features: features bootstrap: features/bootstrap
  • 33. And the last step… php bin/behat --init And now you have your Features folder where you can create the magic!!!
  • 34. What are the features?
  • 35. Let's Have Behat Analyze Our Feature
  • 36. Behat Creates the Glue ...but the rest is up to you
  • 37. Not so fast. What about Mink?
  • 38. Understanding Mink One of the most important parts in the web is a browser. A browser is the window through which web application users interact with the application and other users.
  • 39. Headless browser emulators VS Browser controllers
  • 40. Selenium2Driver • Control the Browser – Session • Cookies and Headers management • HTTP Authentication • Traverse the Page - Selectors • Manipulate the Page
  • 41. Mink Context Defines Steps ...for making requests
  • 42. Mink Context Defines Steps ...for interacting with forms
  • 43. Mink Context Defines Steps ...for querying the DOM
  • 44. Mink Context Defines Steps ...for examining responses
  • 45. Now… Let’s get away from the theory and show some action!
  • 46. Tags Tags are a great way to organize your features and scenarios: A Scenario or Feature can have as many tags as you like, just separate them with spaces:
  • 47. Tags How to execute the tags? If a tag exists on a Feature, Behat will assign that tag to all child Scenarios and Scenario Outlines too!
  • 48. Behat.yml All configuration happens inside a single configuration file in the YAML format.
  • 49. Imports …or share your feature configurations
  • 50. Profiles $bin/behat –p google features/feature1
  • 51. The Drupal extension • Overrides default behaviors: – Snippets follow Drupal coding standards – Mink Extension steps get synonyms for readability • Provides drivers to facilitate data setup – Blackbox – Drush – Drupal API • Adds support for Drupal: – Regions – Node types – Users and Roles – Taxonomy – Subcontexts for Contributed Modules
  • 52. Provides drivers for data set up • Works with Drupal 6, 7, and 8 • Connect with no privileges (local or remote) • Connect with Drush (local or remote) • Connect with the Drupal API (local only)
  • 53. Drush: alias file http://drush.ws/examples/example.aliases.drushrc.php
  • 57. Regions Requires a map in the behat.yml file • label => css selector • This means regions don’t have to map directly to Drupal theme regions
  • 58. Structure > Blocks > (Theme) > Demonstrate block regions
  • 59. Nodes
  • 60. Users, roles and taxonomies
  • 63. If you have any questions or you want access for the full installation guideline feel free to contact me on my email address: bboshnakov91@gmail.com
  • 64. Resources • http://dspeak.com/pnwds/6-drupalextension.html • http://docs.behat.org/guides/7.config.html • http://behat.org/ • http://mink.behat.org/ • https://amsterdam2014.drupal.org/session/doing-behaviour- driven-development-behat

Notes de l'éditeur

  1. Most of the programmers are smart and it is very important when building software. What I mean…
  2. This is not good for big projects
  3. This is not good for big projects
  4. This is not good for big projects
  5. В ТДД тестовете реално не са тестове а примери как функционалностите трябва работят! Но оставям на вас да прецените кои са силните и слабите страни на този метод на работа. TDD Defined: - Decide what the code will do Write a test that will pass if the code does that thing Run the test, see it fail Write the code Run the test see it pass TDD Provides: Design and plan before you code Document your design Proof that code implements design Encourages design of testable code
  6. “BDD is about implementing an application by describing its behavior from the perspective of its stakeholders.” – Dan North The original developer of BDD (Dan North) came up with the notion of BDD because he was dissatisfied with the lack of any specification within TDD of what should be tested and how. BDD – Second generation of agile methodology User stories Domain-Driven Development Extreme Programmin TDD Acceptance Driven Test Planning Continuous integration
  7. “BDD is about implementing an application by describing its behavior from the perspective of its stakeholders.” – Dan North The original developer of BDD (Dan North) came up with the notion of BDD because he was dissatisfied with the lack of any specification within TDD of what should be tested and how. BDD – Second generation of agile methodology User stories Domain-Driven Development Extreme Programmin TDD Acceptance Driven Test Planning Continuous integration
  8. Everzet Konstantin Kudryashov -> Въпроси за техният бизнес -> Започнете да доставяте софтуер който се ползва и наистина удовлетворява клиента. Не започвайте да с tools, а с разговори и въпроси!!!!
  9. Сега ще покажа прост пример как да опишем тези неща.
  10. Само бърз пример за да ви покажа нагледно как изразяваме тези стъпки в програмен код.
  11. И сега ще си поговорим как точно да сложим бехат на нашите локални машини.
  12. Composer is a tool for dependency management in PHP. It allows you to declare the dependent libraries your project needs and it will install them in your project for you.
  13. This file is the Composer binary. It is a PHAR (PHP archive), which is an archive format for PHP which can be run on the command line, amongst other things.
  14. Sometimes, Behat’s default configuration is not enough. Some day you’ll need some extended tools to configure your feature suite. For that day, Behat has a very powerful configuration system based on YAML configuration files and profiles.
  15. Every *.feature file conventionally consists of a single feature. Lines starting with the keyword Feature: (or its localized equivalent) followed by three indented lines starts a feature. A feature usually contains a list of scenarios. You can write whatever you want up until the first scenario, which starts withScenario: (or localized equivalent) on a new line. You can use tags to group features and scenarios together, independent of your file and directory structure. Every scenario consists of a list of steps, which must start with one of the keywords Given, When, Then, But or And (or localized one). Behat treats them all the same, but you shouldn’t. Here is an example:
  16. There’s huge amount of browser emulators out there, like Goutte, Selenium, Sahi and others. They all do the same job, but do it very differently. They behave differently and have very different API’s. But, what’s more important - there’s actually 2 completely different types of browser emulators out there: Headless browser emulators Browser controllers
  17. First type browsers are simple pure HTTP specification implementations, likeGoutte. Those browser emulators send a real HTTP requests against an application and parse the response content. They are very simple to run and configure, because this type of emulators can be written in any available programming language and can be run through console on servers without GUI. Headless emulators have both, advantages and disadvantages. Advantages are simplicity, speed and ability to run it without the need in real browser. But this type of browsers have one big disadvantage - they have no JS/AJAX support. So, you can’t test your rich GUI web applications with headless browsers. Second browser emulators type are browser controllers. Those emulators aims to control the real browser. That’s right, a program to control another program. Browser controllers simulate user interactions on browser and are able to retrieve actual information from current browser page. Selenium and Sahi are two most famous browser controllers. The main advantage of browser controllers usage is the support for JS/AJAX interactions on page. Disadvantage is that such browser emulators require installed browser, extra configuration are usually much slower than headless counterparts.
  18. All of one team's tests: bin/behat features/folder A single feature: bin/behat features/folder/filename.feature A single scenario within a feature: bin/behat features/teamname/filename.feature:7 where 7 represents the first line of the scenario. Exclude the tagname if present. All tests with a certain tag: bin/behat --tags @tagname All tests except a certain tag: bin/behat --tags ~tagname Multiple tags: bin/behat --tags "@tagname1&&@tagname2&&~@tagname3" By adding an @javascript tag above the feature (for all the scenarios) or above a single scenario, the test will use Selenium and Firefox to run the test. These defaults can be changed in the behat.yml file.
  19. Behat tries to load behat.yml or config/behat.yml by default, or you can tell Behat where your config file is with the --config option: Paths Formatter Colors Context Imports Environment Variable
  20. The imports block allows you to share your feature suite configuration between projects and their test suites. All files from the imports block will be loaded by Behat and merged into yourbehat.yml config.
  21. Profiles Extensions
  22. Profiles Extensions
  23. Profiles Extensions
  24. Examples
  25. Profiles Extensions
  26. The RegexpMapper changes filenames according to a pattern defined by a regular expression. This is the most powerful mapper and you should be able to use it for every possible application.
  27. The RegexpMapper changes filenames according to a pattern defined by a regular expression. This is the most powerful mapper and you should be able to use it for every possible application.