SlideShare a Scribd company logo
Integration Testing with Behat
Oscar Merida
March 2016
Why Automated Testing
● Old school “Click around to see if anything broke”
● Should want a process that is:
– Repeatable
– Can be automated
– Not Prone to Human Error
Forms of Testing
● Unit Testing / TDD
● Integration Tests
● UI Testing
● Performance or Load Testing
Behat / Mink
● Behat is a Behavior Driven Developement
framework to help communicate how an
application should behave.
● Mink is an extension to allow website testing by
simulating interacting with it through a browser
– Goutte: makes request, parses content, no JS
– Selenium: controls a real browser, more setup.
Installation
●
In your project root with Composer:
composer require behat/behat
composer require behat/mink
composer require behat/mink-selection2-driver
composer require behat/mink-selenium2-driver
composer require behat/mink-extension
●
Or in your composer.json file:
"require": {
"behat/behat": "^3.0",
"behat/mink": "^1.7",
"behat/mink-selenium2-driver": "^1.3",
"behat/mink-extension": "^2.1"
},
Verify Installation
● Behat and it's dependencies will download to your
'vendor/' folder
● Can check that it works with:
vendo/bin/behat -V
Drupal Integration
● The Behat Drupal Exentions integrates Behat,
Mink, and Drupal.
● Provides out-of-the-box tests that are Drupal
aware.
● Install with:
composer require drupal/drupal-extension
Configuration
● Be default looks for a “behat.yml” file.
● First part – configures contexts
default:
suites:
default:
contexts:
- DrupalDrupalExtensionContextDrupalContext
- DrupalDrupalExtensionContextMarkupContext
- DrupalDrupalExtensionContextMessageContext
- FeatureContext
Configuring extensions
● Additional configuration for Selenium integration
extensions:
BehatMinkExtension:
goutte: ~
javascript_session: selenium2
selenium2:
wd_host: http://local.dev:4444/wd/hub
base_url: http://local.dev
Configuring DrupalExtension
● Tell it about your site's regions
DrupalDrupalExtension:
blackbox: ~
region_map:
breadcrumb: '#breadcrumb'
branding: '#region-branding'
branding_second: '#region-branding-second'
content: '#region-content'
content_zone: '#zone-content'
Writing a Feature
● A “Feature” is a set of tests in a plain text file
● Use “vendor/bin/behat --init” to create a features
directory.
● You can have more than one feature file:
– “blog.feature”
– “members.feature”
– “homepage.feature”
Global Elements feature
● Checks that certain blocks are present
Feature: Global Elements
Scenario: Homepage Contact Us Link
Given I am on the homepage
Then I should see the link "Contact Us" in the "branding_second" region
Then I should see the "Search" button in the "branding_second" region
Then I should see the "div#block-system-main-menu" element in the "menu"
region

More Related Content

PPTX
PDF
WordPress development checklist
PPTX
Webpack
PDF
Webpack DevTalk
PPTX
#2 Hanoi Magento Meetup - Part 2: Knockout JS
PPTX
Improving build solutions dependency management with webpack
PPTX
Packing for the Web with Webpack
PDF
Bundle your modules with Webpack
WordPress development checklist
Webpack
Webpack DevTalk
#2 Hanoi Magento Meetup - Part 2: Knockout JS
Improving build solutions dependency management with webpack
Packing for the Web with Webpack
Bundle your modules with Webpack

What's hot (20)

PDF
Webpack: from 0 to 2
PPT
TDD with ASP.NET MVC 1.0
PPTX
Angular 1.5 Components
PPTX
Migrando una app de angular.js a Blazor
PDF
Webpack & React Performance in 16+ Steps
PPT
Introduction to ASP.NET MVC 1.0
PDF
Why gradle
PDF
Grunt.js and Yeoman, Continous Integration
ODP
Test Automation Framework using Cucumber BDD Overview - part 2
PDF
OpenCms Days 2013 - Start rolling with OpenCms 9
PDF
Optimising Your Front End Workflow With Symfony, Twig, Bower and Gulp
PDF
Ride on the Fast Track of Web with Ruby on Rails- Part 2
PPT
ColdFusion framework comparison
PPT
Maven – The build paraphernalia
ODP
Kickstart Jpa
PPTX
SenchaCon 2016: Building Enterprise Ext JS Apps with Mavenized Sencha Cmd - F...
PPT
Drupal Workflow Concepts
PDF
Internationalizing The New York Times
PDF
OpenCms Days 2015 Hidden features of OpenCms
PPT
Google App Engine with JSF 2.x
Webpack: from 0 to 2
TDD with ASP.NET MVC 1.0
Angular 1.5 Components
Migrando una app de angular.js a Blazor
Webpack & React Performance in 16+ Steps
Introduction to ASP.NET MVC 1.0
Why gradle
Grunt.js and Yeoman, Continous Integration
Test Automation Framework using Cucumber BDD Overview - part 2
OpenCms Days 2013 - Start rolling with OpenCms 9
Optimising Your Front End Workflow With Symfony, Twig, Bower and Gulp
Ride on the Fast Track of Web with Ruby on Rails- Part 2
ColdFusion framework comparison
Maven – The build paraphernalia
Kickstart Jpa
SenchaCon 2016: Building Enterprise Ext JS Apps with Mavenized Sencha Cmd - F...
Drupal Workflow Concepts
Internationalizing The New York Times
OpenCms Days 2015 Hidden features of OpenCms
Google App Engine with JSF 2.x
Ad

Viewers also liked (20)

PDF
Behat dpc12
PPTX
[BDD] Introduction to Behat (PL)
PDF
Acceptance & Integration Testing With Behat (PBC11)
DOCX
Resultados finales del estudio de campo
PDF
rezaee ramezani bazrgar 2015
PDF
MOKO Social Media Overview (1.29.16)
PPTX
ما هو اختبار أبجار
PPTX
Desarrollo del periodismo digital
PDF
Academic Transcript - Rafael de Oliveira Sakai
PDF
Acceptance & Integration Testing With Behat (PHPNw2011)
PPTX
THE GOLDEN STANDARD IN NEW YORK CITY MANSIONS 20K SF $80MM
PDF
Web Acceptance Testing with Behat
PDF
Moving with the times - E-Tourism 14Sep16
PDF
DDD with Behat
PDF
Derecho Informático en Bolivia 2014
PPT
Cognitivo conductual (1)
PPT
Discipline model
PPTX
170 رسائل خاصة من أطفال متلازمة داون إليكم جميعاً
PDF
BC Business - Renewal
Behat dpc12
[BDD] Introduction to Behat (PL)
Acceptance & Integration Testing With Behat (PBC11)
Resultados finales del estudio de campo
rezaee ramezani bazrgar 2015
MOKO Social Media Overview (1.29.16)
ما هو اختبار أبجار
Desarrollo del periodismo digital
Academic Transcript - Rafael de Oliveira Sakai
Acceptance & Integration Testing With Behat (PHPNw2011)
THE GOLDEN STANDARD IN NEW YORK CITY MANSIONS 20K SF $80MM
Web Acceptance Testing with Behat
Moving with the times - E-Tourism 14Sep16
DDD with Behat
Derecho Informático en Bolivia 2014
Cognitivo conductual (1)
Discipline model
170 رسائل خاصة من أطفال متلازمة داون إليكم جميعاً
BC Business - Renewal
Ad

Similar to Integration Testing with Behat drupal (20)

PDF
Effizientere WordPress-Plugin-Entwicklung mit Softwaretests
PDF
Continuous integration / continuous delivery
PPTX
Continuous integration / continuous delivery of web applications, Eugen Kuzmi...
PPTX
Continuous Integration/ Continuous Delivery of web applications
PPTX
Automation in Drupal
PDF
Development Setup of B-Translator
PDF
Strategies and Tips for Building Enterprise Drupal Applications - PNWDS 2013
PPTX
#3 Hanoi Magento Meetup - Part 2: Scalable Magento Development With Containers
PDF
Profiling PHP with Xdebug / Webgrind
PPT
Maven 2.0 - Project management and comprehension tool
PDF
Behat internals for advanced usage. Symfony Camp 2016
ODP
ODP
Behat Workshop at WeLovePHP
PDF
Magento 2 Development
PPTX
CISOA Conference 2020 Banner 9 Development
PDF
ICONUK 2015 - Gradle Up!
PDF
Creating a Smooth Development Workflow for High-Quality Modular Open-Source P...
PDF
Magento Performance Optimization 101
PDF
Configuration as Dependency: Managing Drupal 8 Configuration with git and Com...
PPT
Slim3 quick start
Effizientere WordPress-Plugin-Entwicklung mit Softwaretests
Continuous integration / continuous delivery
Continuous integration / continuous delivery of web applications, Eugen Kuzmi...
Continuous Integration/ Continuous Delivery of web applications
Automation in Drupal
Development Setup of B-Translator
Strategies and Tips for Building Enterprise Drupal Applications - PNWDS 2013
#3 Hanoi Magento Meetup - Part 2: Scalable Magento Development With Containers
Profiling PHP with Xdebug / Webgrind
Maven 2.0 - Project management and comprehension tool
Behat internals for advanced usage. Symfony Camp 2016
Behat Workshop at WeLovePHP
Magento 2 Development
CISOA Conference 2020 Banner 9 Development
ICONUK 2015 - Gradle Up!
Creating a Smooth Development Workflow for High-Quality Modular Open-Source P...
Magento Performance Optimization 101
Configuration as Dependency: Managing Drupal 8 Configuration with git and Com...
Slim3 quick start

More from Oscar Merida (11)

PDF
PHP OOP
PDF
Start using PHP 7
PDF
Symfony console: build awesome command line scripts with ease
PDF
Staying Sane with Drupal NEPHP
PDF
Building with Virtual Development Environments
PDF
Staying Sane with Drupal (A Develper's Survival Guide)
PDF
How to Evaluate your Technical Partner
PDF
Building with Virtual Development Environments
PDF
Publishing alchemy with markdown and pandoc
PDF
Migrate without migranes
PDF
Hitch yourwagon
PHP OOP
Start using PHP 7
Symfony console: build awesome command line scripts with ease
Staying Sane with Drupal NEPHP
Building with Virtual Development Environments
Staying Sane with Drupal (A Develper's Survival Guide)
How to Evaluate your Technical Partner
Building with Virtual Development Environments
Publishing alchemy with markdown and pandoc
Migrate without migranes
Hitch yourwagon

Recently uploaded (20)

PPTX
Embracing Complexity in Serverless! GOTO Serverless Bengaluru
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PPTX
Transform Your Business with a Software ERP System
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PDF
2025 Textile ERP Trends: SAP, Odoo & Oracle
PPTX
ai tools demonstartion for schools and inter college
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PDF
Understanding Forklifts - TECH EHS Solution
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PPTX
Introduction to Artificial Intelligence
Embracing Complexity in Serverless! GOTO Serverless Bengaluru
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
Navsoft: AI-Powered Business Solutions & Custom Software Development
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
Design an Analysis of Algorithms I-SECS-1021-03
Transform Your Business with a Software ERP System
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
Wondershare Filmora 15 Crack With Activation Key [2025
Internet Downloader Manager (IDM) Crack 6.42 Build 41
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
2025 Textile ERP Trends: SAP, Odoo & Oracle
ai tools demonstartion for schools and inter college
Which alternative to Crystal Reports is best for small or large businesses.pdf
Understanding Forklifts - TECH EHS Solution
Odoo Companies in India – Driving Business Transformation.pdf
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
How to Choose the Right IT Partner for Your Business in Malaysia
Introduction to Artificial Intelligence

Integration Testing with Behat drupal

  • 1. Integration Testing with Behat Oscar Merida March 2016
  • 2. Why Automated Testing ● Old school “Click around to see if anything broke” ● Should want a process that is: – Repeatable – Can be automated – Not Prone to Human Error
  • 3. Forms of Testing ● Unit Testing / TDD ● Integration Tests ● UI Testing ● Performance or Load Testing
  • 4. Behat / Mink ● Behat is a Behavior Driven Developement framework to help communicate how an application should behave. ● Mink is an extension to allow website testing by simulating interacting with it through a browser – Goutte: makes request, parses content, no JS – Selenium: controls a real browser, more setup.
  • 5. Installation ● In your project root with Composer: composer require behat/behat composer require behat/mink composer require behat/mink-selection2-driver composer require behat/mink-selenium2-driver composer require behat/mink-extension ● Or in your composer.json file: "require": { "behat/behat": "^3.0", "behat/mink": "^1.7", "behat/mink-selenium2-driver": "^1.3", "behat/mink-extension": "^2.1" },
  • 6. Verify Installation ● Behat and it's dependencies will download to your 'vendor/' folder ● Can check that it works with: vendo/bin/behat -V
  • 7. Drupal Integration ● The Behat Drupal Exentions integrates Behat, Mink, and Drupal. ● Provides out-of-the-box tests that are Drupal aware. ● Install with: composer require drupal/drupal-extension
  • 8. Configuration ● Be default looks for a “behat.yml” file. ● First part – configures contexts default: suites: default: contexts: - DrupalDrupalExtensionContextDrupalContext - DrupalDrupalExtensionContextMarkupContext - DrupalDrupalExtensionContextMessageContext - FeatureContext
  • 9. Configuring extensions ● Additional configuration for Selenium integration extensions: BehatMinkExtension: goutte: ~ javascript_session: selenium2 selenium2: wd_host: http://local.dev:4444/wd/hub base_url: http://local.dev
  • 10. Configuring DrupalExtension ● Tell it about your site's regions DrupalDrupalExtension: blackbox: ~ region_map: breadcrumb: '#breadcrumb' branding: '#region-branding' branding_second: '#region-branding-second' content: '#region-content' content_zone: '#zone-content'
  • 11. Writing a Feature ● A “Feature” is a set of tests in a plain text file ● Use “vendor/bin/behat --init” to create a features directory. ● You can have more than one feature file: – “blog.feature” – “members.feature” – “homepage.feature”
  • 12. Global Elements feature ● Checks that certain blocks are present Feature: Global Elements Scenario: Homepage Contact Us Link Given I am on the homepage Then I should see the link "Contact Us" in the "branding_second" region Then I should see the "Search" button in the "branding_second" region Then I should see the "div#block-system-main-menu" element in the "menu" region