SlideShare a Scribd company logo
1
BDD with Behat &
Drupal
Alessio Piazza
Software Developer @SparkFabrik
(twinbit + agavee)
twitter: @alessiopiazza
I do stuff with Drupal
SPARKFABRIK
3
• Behaviour Driven Development
• a software development process that emerged
from TDD (Test Driven Development)
• Behaviour driven development specifies that
tests of any unit of software should be specified
in terms of the desired behaviour of the unit
BDD
SPARKFABRIK
WHY BDD? or TDD?
• You must test your application
• Save your self from regressions (fix one thing,
break another one)
• Save your self from misunderstanding between
you and your client
• Your tests become specification
4
SPARKFABRIK
BDD Workflow
1. Write a specification feature
2. Implement its test
3. Run test and watch it FAIL
4. Change your app to make test PASS
5. Run test and watch it PASS
6. Repat from 2-5 until all GREEN
5
SPARKFABRIK
BDD: HOW IT WORKS?
6
HOW IT WORKS?
7
Write a specification feature
8
Feature: Download Drupal 8
In order to use Drupal 8
as a user
i should be able to download it from drupal.org
Scenario: Download Drupal 8 from Drupal.org
Given i am on the homepage
When i Click “Download and Extend”
Then I should see the link “Download Drupal 8.0.0”
Scenario: …
SPARKFABRIK
SCENARIO STRUCTURE
9
Scenario: Download Drupal 8 from Drupal.org
Given I am on drupal.org homepage
When I Click “Download and Extend”
Then I should see the link “Download Drupal 8.0.0”
SPARKFABRIK
SCENARIO STRUCTURE
10
Given i am on drupal.org homepage
And i Click “Download and Extend”
Then I should see the link “Download Drupal 8.0.0”
Scenario: Download Drupal 8 from Drupal.org
Keyword Description
SPARKFABRIK
SCENARIO STRUCTURE
11
Given i am on drupal.org homepage
And i Click “Download and Extend”
Then I should see the link “Download Drupal 8.0.0”
Scenario: Download Drupal 8 from Drupal.org
Keyword Description
Steps
Given I am on drupal.org homepage
When I Click “Download and Extend”
Then I should see the link “Download …”
SPARKFABRIK
STEPS: Keywords
12
Given -> To put the system in a known state
Given I am an anonymous user
SPARKFABRIK
Given
STEPS: Keywords
13
When -> To describe the key action to performs
When I click on the link
SPARKFABRIK
Given
STEPS: Keywords
14
When
Then -> To to observe outcomes
Then I should see the text “Hello”
SPARKFABRIK
Given
STEPS: Keywords
15
When
Then
And / But -> To make our scenario more readable
SPARKFABRIK
STEPS: Keywords
16
Scenario: Download Drupal 8 from Drupal.org
Given I am on drupal.org homepage
Given I am an anonymous user
When I Click “Download and Extend”
When I Click “Download Drupal 8.0.0”
Then I should see the link “Drupal Core 8.0.0”
SPARKFABRIK
STEPS: Keywords
17
Scenario: Download Drupal 8 from Drupal.org
Given I am on drupal.org homepage
And I am an anonymous user
When I Click “Download and Extend”
And I Click “Download Drupal 8.0.0”
Then I should see the link “Drupal Core 8.0.0”
SPARKFABRIK
GHERKIN
• It is a Business Readable, Domain Specific
Language
• Lets you describe software’s behaviour without
detailing how that behaviour is implemented.
• Gherkin is the language that BEHAT
understands.
18
SPARKFABRIK
BEHAT
docs.behat.org/en/v3.0/
Open source Behavior Driven Development
framework for PHP (5.3+)
Inspired from Cucumber (Ruby)
www.cucumber.io
From version 3 BEHAT it’s an official
Cucumber implementation in PHP
Let us write tests based on our scenarios
19
SPARKFABRIK
HOW BEHAT READS
GHERKIN?
20
Given I am an anonymous user
SPARKFABRIK
HOW BEHAT READS
GHERKIN?
21
/**
* @Given I am an anonymous user
*/
public function assertAnonymousUser() {
// Verify the user is logged out.
if ($this->loggedIn()) {
$this->logout();
}
}
Given I am an anonymous user
SPARKFABRIK
HOW BEHAT READS
GHERKIN?
22
Then I should not see the text :text
SPARKFABRIK
HOW BEHAT READS
GHERKIN?
23
/**
* @Then I should not see the text :text
*/
public function assertNotTextVisible($text) {
// Use the Mink Extension step definition.
$this->assertPageNotContainsText($text);
}
Then I should not see the text :text
SPARKFABRIK
STEP RESULTS
24
/**
* @Then I should not see the text :text
*/
public function assertNotTextVisible($text) {
// This step will fail.
throw new Exception(‘Test failed’);
}
• A step FAILS when an Exception is thrown
SPARKFABRIK
STEP RESULTS
25
/**
* @Then I will trigger a success
*/
public function triggerSuccess() {
// This step will pass.
print(‘Hello DrupalDay’);
}
• A step PASS when no Exception are raised
SPARKFABRIK
OTHER STEP RESULTS
26
• SUCCESSFUL
• FAILED
• PENDING
• UNDEFINED
• SKIPPED
• AMBIGUOUS
• REDUNDANT
SPARKFABRIK
WHERE ARE THESE
STEPS?
27
• STEPS are defined inside plain PHP Object
classes, called CONTEXTS
• MinkContext and DrupalContext give use a lot of
pre-defined steps ready to be used
• Custom steps can be defined inside
FeatureContext class
SPARKFABRIK
Sum Up
28
Give use the syntax
to write features and scenarios
Our framework that reads our
scenarios and run tests
Classes containing our step
definitions
GHERKIN
BEHAT
CONTEXTS
SPARKFABRIK
How we integrate Behat and
Drupal?
29
Behat Drupal Extension
An integration layer between
Drupal and Behat
https://www.drupal.org/project/drupalextension
https://github.com/jhedstrom/drupalextension
SPARKFABRIK
From your project root..
composer require drupal/drupal-extension
30
- Installing drupal/drupal-driver (v1.1.4)
Downloading: 100%
> DrupalCoreComposerComposer::vendorTestCodeCleanup
- Installing symfony/filesystem (v3.0.0)
Downloading: 100%
> DrupalCoreComposerComposer::vendorTestCodeCleanup
- Installing symfony/config (v2.8.0)
Downloading: 100%
> DrupalCoreComposerComposer::vendorTestCodeCleanup
- Installing behat/transliterator (v1.1.0)
Loading from cache
…
…
> DrupalCoreComposerComposer::vendorTestCodeCleanup
- Installing drupal/drupal-extension (v3.1.3)
Downloading: 100% SPARKFABRIK
Create file behat.yml
31
1 default:
2 suites:
3 default:
4 contexts:
5 - FeatureContext
6 - DrupalDrupalExtensionContextDrupalContext
7 - DrupalDrupalExtensionContextMinkContext
8 extensions:
9 BehatMinkExtension:
10 goutte: ~
11 base_url: http://d8.drupalday2015.sparkfabrik.loc # Replace with your site's URL
12 DrupalDrupalExtension:
13 blackbox: ~
see https://github.com/jhedstrom/drupalextension
SPARKFABRIK
Then --init your test suite
32
vendor/bin/behat --init
+d features - place your *.feature files here
+d features/bootstrap - place your context classes here
+f features/bootstrap/FeatureContext.php - place your
definitions, transformations and hooks here
SPARKFABRIK
Demo!
33
SPARKFABRIK
BROWSER INTERACTION
• With BDD we write clear, understandable
scenario
• Our scenario often describe an interaction with
the browser
34
WE NEED A BROWSER EMULATOR
SPARKFABRIK
BROWSER EMULATORS
• Headless browser emulators (Goutte)
• Browser controllers (Selenium2, SAHI)
• They do basically the same thing: control or
emulate browsers but they do them in different
ways
• They comes with their pro and cons
35
SPARKFABRIK
MINK!
http://mink.behat.org/en/latest/
• MINK removes API differences between different browser emulators
• MINK provides different drivers for every browser emulator
• MINK gives you an easy way to
1. control the browser
2. traverse pages
3. manipulate page elements
4. interact with page elements
36
SPARKFABRIK
37
/**
* @When /^(?:|I )move forward one page$/
*/
public function forward() {
$this->getSession()->forward();
}
MINK!
http://mink.behat.org/en/latest/
When I move forward one page
SPARKFABRIK
Wrap up
38
GHERKIN
BEHAT
CONTEXTS
MINK
Give use the syntax
to write features and scenarios
Our framework that reads our
scenarios and run the tests
Classes containing our step
definitions
Describe browser interaction
without worrying about the browser
SPARKFABRIK
39
Ad

More Related Content

What's hot (20)

Ant User Guide
Ant User GuideAnt User Guide
Ant User Guide
Muthuselvam RS
 
Django app deployment in Azure By Saurabh Agarwal
Django app deployment in Azure By Saurabh AgarwalDjango app deployment in Azure By Saurabh Agarwal
Django app deployment in Azure By Saurabh Agarwal
ratneshsinghparihar
 
Build website in_django
Build website in_django Build website in_django
Build website in_django
swee meng ng
 
JBUG 11 - Django-The Web Framework For Perfectionists With Deadlines
JBUG 11 - Django-The Web Framework For Perfectionists With DeadlinesJBUG 11 - Django-The Web Framework For Perfectionists With Deadlines
JBUG 11 - Django-The Web Framework For Perfectionists With Deadlines
Tikal Knowledge
 
Intro to WordPress Plugin Development
Intro to WordPress Plugin DevelopmentIntro to WordPress Plugin Development
Intro to WordPress Plugin Development
Brad Williams
 
Quick flask an intro to flask
Quick flask   an intro to flaskQuick flask   an intro to flask
Quick flask an intro to flask
juzten
 
Web application development with Django framework
Web application development with Django frameworkWeb application development with Django framework
Web application development with Django framework
flapiello
 
Django Architecture Introduction
Django Architecture IntroductionDjango Architecture Introduction
Django Architecture Introduction
Haiqi Chen
 
Django Girls Tutorial
Django Girls TutorialDjango Girls Tutorial
Django Girls Tutorial
Kishimi Ibrahim Ishaq
 
PloneNG: What's new in Plone 4.2, 4.3, and beyond
PloneNG: What's new in Plone 4.2, 4.3, and beyondPloneNG: What's new in Plone 4.2, 4.3, and beyond
PloneNG: What's new in Plone 4.2, 4.3, and beyond
David Glick
 
Introduction to building joomla! components using FOF
Introduction to building joomla! components using FOFIntroduction to building joomla! components using FOF
Introduction to building joomla! components using FOF
Tim Plummer
 
Flask
FlaskFlask
Flask
Mamta Kumari
 
How to create a joomla component from scratch
How to create a joomla component from scratchHow to create a joomla component from scratch
How to create a joomla component from scratch
Tim Plummer
 
Composer & Drupal
Composer & DrupalComposer & Drupal
Composer & Drupal
drubb
 
Django - Python MVC Framework
Django - Python MVC FrameworkDjango - Python MVC Framework
Django - Python MVC Framework
Bala Kumar
 
Build Automation of PHP Applications
Build Automation of PHP ApplicationsBuild Automation of PHP Applications
Build Automation of PHP Applications
Pavan Kumar N
 
Headless Drupal
Headless DrupalHeadless Drupal
Headless Drupal
drubb
 
Python/Flask Presentation
Python/Flask PresentationPython/Flask Presentation
Python/Flask Presentation
Parag Mujumdar
 
Django Framework Overview forNon-Python Developers
Django Framework Overview forNon-Python DevelopersDjango Framework Overview forNon-Python Developers
Django Framework Overview forNon-Python Developers
Rosario Renga
 
Django Documentation
Django DocumentationDjango Documentation
Django Documentation
Ying wei (Joe) Chou
 
Django app deployment in Azure By Saurabh Agarwal
Django app deployment in Azure By Saurabh AgarwalDjango app deployment in Azure By Saurabh Agarwal
Django app deployment in Azure By Saurabh Agarwal
ratneshsinghparihar
 
Build website in_django
Build website in_django Build website in_django
Build website in_django
swee meng ng
 
JBUG 11 - Django-The Web Framework For Perfectionists With Deadlines
JBUG 11 - Django-The Web Framework For Perfectionists With DeadlinesJBUG 11 - Django-The Web Framework For Perfectionists With Deadlines
JBUG 11 - Django-The Web Framework For Perfectionists With Deadlines
Tikal Knowledge
 
Intro to WordPress Plugin Development
Intro to WordPress Plugin DevelopmentIntro to WordPress Plugin Development
Intro to WordPress Plugin Development
Brad Williams
 
Quick flask an intro to flask
Quick flask   an intro to flaskQuick flask   an intro to flask
Quick flask an intro to flask
juzten
 
Web application development with Django framework
Web application development with Django frameworkWeb application development with Django framework
Web application development with Django framework
flapiello
 
Django Architecture Introduction
Django Architecture IntroductionDjango Architecture Introduction
Django Architecture Introduction
Haiqi Chen
 
PloneNG: What's new in Plone 4.2, 4.3, and beyond
PloneNG: What's new in Plone 4.2, 4.3, and beyondPloneNG: What's new in Plone 4.2, 4.3, and beyond
PloneNG: What's new in Plone 4.2, 4.3, and beyond
David Glick
 
Introduction to building joomla! components using FOF
Introduction to building joomla! components using FOFIntroduction to building joomla! components using FOF
Introduction to building joomla! components using FOF
Tim Plummer
 
How to create a joomla component from scratch
How to create a joomla component from scratchHow to create a joomla component from scratch
How to create a joomla component from scratch
Tim Plummer
 
Composer & Drupal
Composer & DrupalComposer & Drupal
Composer & Drupal
drubb
 
Django - Python MVC Framework
Django - Python MVC FrameworkDjango - Python MVC Framework
Django - Python MVC Framework
Bala Kumar
 
Build Automation of PHP Applications
Build Automation of PHP ApplicationsBuild Automation of PHP Applications
Build Automation of PHP Applications
Pavan Kumar N
 
Headless Drupal
Headless DrupalHeadless Drupal
Headless Drupal
drubb
 
Python/Flask Presentation
Python/Flask PresentationPython/Flask Presentation
Python/Flask Presentation
Parag Mujumdar
 
Django Framework Overview forNon-Python Developers
Django Framework Overview forNon-Python DevelopersDjango Framework Overview forNon-Python Developers
Django Framework Overview forNon-Python Developers
Rosario Renga
 

Similar to Behaviour Driven Development con Behat & Drupal (20)

Voiture tech talk
Voiture tech talkVoiture tech talk
Voiture tech talk
Hoppinger
 
Virtual Environment and Web development using Django
Virtual Environment and Web development using DjangoVirtual Environment and Web development using Django
Virtual Environment and Web development using Django
Sunil kumar Mohanty
 
Deploying Symfony | symfony.cat
Deploying Symfony | symfony.catDeploying Symfony | symfony.cat
Deploying Symfony | symfony.cat
Pablo Godel
 
‘Hello, world!’ application how to dockerize golang application
‘Hello, world!’ application how to dockerize golang application‘Hello, world!’ application how to dockerize golang application
‘Hello, world!’ application how to dockerize golang application
Katy Slemon
 
Ultimate Survival - React-Native edition
Ultimate Survival - React-Native editionUltimate Survival - React-Native edition
Ultimate Survival - React-Native edition
Richard Radics
 
Write your first WordPress plugin
Write your first WordPress pluginWrite your first WordPress plugin
Write your first WordPress plugin
Anthony Montalbano
 
Bugzilla Installation Process
Bugzilla Installation ProcessBugzilla Installation Process
Bugzilla Installation Process
Vino Harikrishnan
 
A Presentation of Dash Enterprise and Its Interface.pptx
A Presentation of Dash Enterprise and Its Interface.pptxA Presentation of Dash Enterprise and Its Interface.pptx
A Presentation of Dash Enterprise and Its Interface.pptx
MusaBadaru
 
20130528 solution linux_frousseau_nopain_webdev
20130528 solution linux_frousseau_nopain_webdev20130528 solution linux_frousseau_nopain_webdev
20130528 solution linux_frousseau_nopain_webdev
Frank Rousseau
 
Spring Live Sample Chapter
Spring Live Sample ChapterSpring Live Sample Chapter
Spring Live Sample Chapter
Syed Shahul
 
Hands on Docker - Launch your own LEMP or LAMP stack
Hands on Docker -  Launch your own LEMP or LAMP stackHands on Docker -  Launch your own LEMP or LAMP stack
Hands on Docker - Launch your own LEMP or LAMP stack
Dana Luther
 
Mojolicious
MojoliciousMojolicious
Mojolicious
Marcus Ramberg
 
Learning Docker with Thomas
Learning Docker with ThomasLearning Docker with Thomas
Learning Docker with Thomas
Thomas Tong, FRM, PMP
 
Drupal Day 2012 - Automating Drupal Development: Make!les, Features and Beyond
Drupal Day 2012 - Automating Drupal Development: Make!les, Features and BeyondDrupal Day 2012 - Automating Drupal Development: Make!les, Features and Beyond
Drupal Day 2012 - Automating Drupal Development: Make!les, Features and Beyond
DrupalDay
 
Docker for Ruby Developers
Docker for Ruby DevelopersDocker for Ruby Developers
Docker for Ruby Developers
Aptible
 
Hands on Docker - Launch your own LEMP or LAMP stack - SunshinePHP
Hands on Docker - Launch your own LEMP or LAMP stack - SunshinePHPHands on Docker - Launch your own LEMP or LAMP stack - SunshinePHP
Hands on Docker - Launch your own LEMP or LAMP stack - SunshinePHP
Dana Luther
 
Обход проверки безопасности в магазинах мобильных приложений при помощи платф...
Обход проверки безопасности в магазинах мобильных приложений при помощи платф...Обход проверки безопасности в магазинах мобильных приложений при помощи платф...
Обход проверки безопасности в магазинах мобильных приложений при помощи платф...
Positive Hack Days
 
Development Setup of B-Translator
Development Setup of B-TranslatorDevelopment Setup of B-Translator
Development Setup of B-Translator
Dashamir Hoxha
 
DockerCon EU 2018 - Dockerfile Best Practices
DockerCon EU 2018 - Dockerfile Best PracticesDockerCon EU 2018 - Dockerfile Best Practices
DockerCon EU 2018 - Dockerfile Best Practices
Tibor Vass
 
DCEU 18: Dockerfile Best Practices
DCEU 18: Dockerfile Best PracticesDCEU 18: Dockerfile Best Practices
DCEU 18: Dockerfile Best Practices
Docker, Inc.
 
Voiture tech talk
Voiture tech talkVoiture tech talk
Voiture tech talk
Hoppinger
 
Virtual Environment and Web development using Django
Virtual Environment and Web development using DjangoVirtual Environment and Web development using Django
Virtual Environment and Web development using Django
Sunil kumar Mohanty
 
Deploying Symfony | symfony.cat
Deploying Symfony | symfony.catDeploying Symfony | symfony.cat
Deploying Symfony | symfony.cat
Pablo Godel
 
‘Hello, world!’ application how to dockerize golang application
‘Hello, world!’ application how to dockerize golang application‘Hello, world!’ application how to dockerize golang application
‘Hello, world!’ application how to dockerize golang application
Katy Slemon
 
Ultimate Survival - React-Native edition
Ultimate Survival - React-Native editionUltimate Survival - React-Native edition
Ultimate Survival - React-Native edition
Richard Radics
 
Write your first WordPress plugin
Write your first WordPress pluginWrite your first WordPress plugin
Write your first WordPress plugin
Anthony Montalbano
 
Bugzilla Installation Process
Bugzilla Installation ProcessBugzilla Installation Process
Bugzilla Installation Process
Vino Harikrishnan
 
A Presentation of Dash Enterprise and Its Interface.pptx
A Presentation of Dash Enterprise and Its Interface.pptxA Presentation of Dash Enterprise and Its Interface.pptx
A Presentation of Dash Enterprise and Its Interface.pptx
MusaBadaru
 
20130528 solution linux_frousseau_nopain_webdev
20130528 solution linux_frousseau_nopain_webdev20130528 solution linux_frousseau_nopain_webdev
20130528 solution linux_frousseau_nopain_webdev
Frank Rousseau
 
Spring Live Sample Chapter
Spring Live Sample ChapterSpring Live Sample Chapter
Spring Live Sample Chapter
Syed Shahul
 
Hands on Docker - Launch your own LEMP or LAMP stack
Hands on Docker -  Launch your own LEMP or LAMP stackHands on Docker -  Launch your own LEMP or LAMP stack
Hands on Docker - Launch your own LEMP or LAMP stack
Dana Luther
 
Drupal Day 2012 - Automating Drupal Development: Make!les, Features and Beyond
Drupal Day 2012 - Automating Drupal Development: Make!les, Features and BeyondDrupal Day 2012 - Automating Drupal Development: Make!les, Features and Beyond
Drupal Day 2012 - Automating Drupal Development: Make!les, Features and Beyond
DrupalDay
 
Docker for Ruby Developers
Docker for Ruby DevelopersDocker for Ruby Developers
Docker for Ruby Developers
Aptible
 
Hands on Docker - Launch your own LEMP or LAMP stack - SunshinePHP
Hands on Docker - Launch your own LEMP or LAMP stack - SunshinePHPHands on Docker - Launch your own LEMP or LAMP stack - SunshinePHP
Hands on Docker - Launch your own LEMP or LAMP stack - SunshinePHP
Dana Luther
 
Обход проверки безопасности в магазинах мобильных приложений при помощи платф...
Обход проверки безопасности в магазинах мобильных приложений при помощи платф...Обход проверки безопасности в магазинах мобильных приложений при помощи платф...
Обход проверки безопасности в магазинах мобильных приложений при помощи платф...
Positive Hack Days
 
Development Setup of B-Translator
Development Setup of B-TranslatorDevelopment Setup of B-Translator
Development Setup of B-Translator
Dashamir Hoxha
 
DockerCon EU 2018 - Dockerfile Best Practices
DockerCon EU 2018 - Dockerfile Best PracticesDockerCon EU 2018 - Dockerfile Best Practices
DockerCon EU 2018 - Dockerfile Best Practices
Tibor Vass
 
DCEU 18: Dockerfile Best Practices
DCEU 18: Dockerfile Best PracticesDCEU 18: Dockerfile Best Practices
DCEU 18: Dockerfile Best Practices
Docker, Inc.
 
Ad

More from sparkfabrik (20)

Talks on my machine: Drupal, Storybook e SDC
Talks on my machine: Drupal, Storybook e SDCTalks on my machine: Drupal, Storybook e SDC
Talks on my machine: Drupal, Storybook e SDC
sparkfabrik
 
Talks on my machine: Drupal CMS versus The Cool Kids
Talks on my machine: Drupal CMS versus The Cool KidsTalks on my machine: Drupal CMS versus The Cool Kids
Talks on my machine: Drupal CMS versus The Cool Kids
sparkfabrik
 
Talks on my machine: Drupal: AI e Typesense come integrare la ricerca semantica
Talks on my machine:  Drupal: AI e Typesense come integrare la ricerca semanticaTalks on my machine:  Drupal: AI e Typesense come integrare la ricerca semantica
Talks on my machine: Drupal: AI e Typesense come integrare la ricerca semantica
sparkfabrik
 
KCD Italy 2023 - Secure Software Supply chain for OCI Artifact on Kubernetes
KCD Italy 2023 - Secure Software Supply chain for OCI Artifact on KubernetesKCD Italy 2023 - Secure Software Supply chain for OCI Artifact on Kubernetes
KCD Italy 2023 - Secure Software Supply chain for OCI Artifact on Kubernetes
sparkfabrik
 
20231129 - Platform @ localhost 2023 - Application-driven infrastructure with...
20231129 - Platform @ localhost 2023 - Application-driven infrastructure with...20231129 - Platform @ localhost 2023 - Application-driven infrastructure with...
20231129 - Platform @ localhost 2023 - Application-driven infrastructure with...
sparkfabrik
 
IAD 2023 - 22 Years of Agile and all I got is this lousy t-shirt
IAD 2023 - 22 Years of Agile and all I got is this lousy t-shirtIAD 2023 - 22 Years of Agile and all I got is this lousy t-shirt
IAD 2023 - 22 Years of Agile and all I got is this lousy t-shirt
sparkfabrik
 
2023 - Drupalcon - How Drupal builds your pages
2023 - Drupalcon - How Drupal builds your pages2023 - Drupalcon - How Drupal builds your pages
2023 - Drupalcon - How Drupal builds your pages
sparkfabrik
 
2023 - TAC23 - Agile HR - Racconti dal fronte
2023 - TAC23 - Agile HR - Racconti dal fronte2023 - TAC23 - Agile HR - Racconti dal fronte
2023 - TAC23 - Agile HR - Racconti dal fronte
sparkfabrik
 
CodeMotion 2023 - Deep dive nella supply chain della nostra infrastruttura cl...
CodeMotion 2023 - Deep dive nella supply chain della nostra infrastruttura cl...CodeMotion 2023 - Deep dive nella supply chain della nostra infrastruttura cl...
CodeMotion 2023 - Deep dive nella supply chain della nostra infrastruttura cl...
sparkfabrik
 
What is the Secure Supply Chain and the Current State of the PHP Ecosystem
What is the Secure Supply Chain and the Current State of the PHP EcosystemWhat is the Secure Supply Chain and the Current State of the PHP Ecosystem
What is the Secure Supply Chain and the Current State of the PHP Ecosystem
sparkfabrik
 
UX e Web sostenibile (UXday 2023).pdf
UX e Web sostenibile (UXday 2023).pdfUX e Web sostenibile (UXday 2023).pdf
UX e Web sostenibile (UXday 2023).pdf
sparkfabrik
 
Drupal Dev Days Vienna 2023 - What is the secure software supply chain and th...
Drupal Dev Days Vienna 2023 - What is the secure software supply chain and th...Drupal Dev Days Vienna 2023 - What is the secure software supply chain and th...
Drupal Dev Days Vienna 2023 - What is the secure software supply chain and th...
sparkfabrik
 
Deep dive nella supply chain della nostra infrastruttura cloud
Deep dive nella supply chain della nostra infrastruttura cloudDeep dive nella supply chain della nostra infrastruttura cloud
Deep dive nella supply chain della nostra infrastruttura cloud
sparkfabrik
 
KCD Italy 2022 - Application driven infrastructure with Crossplane
KCD Italy 2022 - Application driven infrastructure with CrossplaneKCD Italy 2022 - Application driven infrastructure with Crossplane
KCD Italy 2022 - Application driven infrastructure with Crossplane
sparkfabrik
 
Come Drupal costruisce le tue pagine
Come Drupal costruisce le tue pagineCome Drupal costruisce le tue pagine
Come Drupal costruisce le tue pagine
sparkfabrik
 
Drupal 10: un framework PHP di sviluppo Cloud Native moderno
Drupal 10: un framework PHP di sviluppo Cloud Native modernoDrupal 10: un framework PHP di sviluppo Cloud Native moderno
Drupal 10: un framework PHP di sviluppo Cloud Native moderno
sparkfabrik
 
Do you know what your Drupal is doing Observe it! (DrupalCon Prague 2022)
Do you know what your Drupal is doing Observe it! (DrupalCon Prague 2022)Do you know what your Drupal is doing Observe it! (DrupalCon Prague 2022)
Do you know what your Drupal is doing Observe it! (DrupalCon Prague 2022)
sparkfabrik
 
Do you know what your Drupal is doing_ Observe it!
Do you know what your Drupal is doing_ Observe it!Do you know what your Drupal is doing_ Observe it!
Do you know what your Drupal is doing_ Observe it!
sparkfabrik
 
Progettare e sviluppare soluzioni serverless con AWS
Progettare e sviluppare soluzioni serverless con AWSProgettare e sviluppare soluzioni serverless con AWS
Progettare e sviluppare soluzioni serverless con AWS
sparkfabrik
 
From React to React Native - Things I wish I knew when I started
From React to React Native - Things I wish I knew when I startedFrom React to React Native - Things I wish I knew when I started
From React to React Native - Things I wish I knew when I started
sparkfabrik
 
Talks on my machine: Drupal, Storybook e SDC
Talks on my machine: Drupal, Storybook e SDCTalks on my machine: Drupal, Storybook e SDC
Talks on my machine: Drupal, Storybook e SDC
sparkfabrik
 
Talks on my machine: Drupal CMS versus The Cool Kids
Talks on my machine: Drupal CMS versus The Cool KidsTalks on my machine: Drupal CMS versus The Cool Kids
Talks on my machine: Drupal CMS versus The Cool Kids
sparkfabrik
 
Talks on my machine: Drupal: AI e Typesense come integrare la ricerca semantica
Talks on my machine:  Drupal: AI e Typesense come integrare la ricerca semanticaTalks on my machine:  Drupal: AI e Typesense come integrare la ricerca semantica
Talks on my machine: Drupal: AI e Typesense come integrare la ricerca semantica
sparkfabrik
 
KCD Italy 2023 - Secure Software Supply chain for OCI Artifact on Kubernetes
KCD Italy 2023 - Secure Software Supply chain for OCI Artifact on KubernetesKCD Italy 2023 - Secure Software Supply chain for OCI Artifact on Kubernetes
KCD Italy 2023 - Secure Software Supply chain for OCI Artifact on Kubernetes
sparkfabrik
 
20231129 - Platform @ localhost 2023 - Application-driven infrastructure with...
20231129 - Platform @ localhost 2023 - Application-driven infrastructure with...20231129 - Platform @ localhost 2023 - Application-driven infrastructure with...
20231129 - Platform @ localhost 2023 - Application-driven infrastructure with...
sparkfabrik
 
IAD 2023 - 22 Years of Agile and all I got is this lousy t-shirt
IAD 2023 - 22 Years of Agile and all I got is this lousy t-shirtIAD 2023 - 22 Years of Agile and all I got is this lousy t-shirt
IAD 2023 - 22 Years of Agile and all I got is this lousy t-shirt
sparkfabrik
 
2023 - Drupalcon - How Drupal builds your pages
2023 - Drupalcon - How Drupal builds your pages2023 - Drupalcon - How Drupal builds your pages
2023 - Drupalcon - How Drupal builds your pages
sparkfabrik
 
2023 - TAC23 - Agile HR - Racconti dal fronte
2023 - TAC23 - Agile HR - Racconti dal fronte2023 - TAC23 - Agile HR - Racconti dal fronte
2023 - TAC23 - Agile HR - Racconti dal fronte
sparkfabrik
 
CodeMotion 2023 - Deep dive nella supply chain della nostra infrastruttura cl...
CodeMotion 2023 - Deep dive nella supply chain della nostra infrastruttura cl...CodeMotion 2023 - Deep dive nella supply chain della nostra infrastruttura cl...
CodeMotion 2023 - Deep dive nella supply chain della nostra infrastruttura cl...
sparkfabrik
 
What is the Secure Supply Chain and the Current State of the PHP Ecosystem
What is the Secure Supply Chain and the Current State of the PHP EcosystemWhat is the Secure Supply Chain and the Current State of the PHP Ecosystem
What is the Secure Supply Chain and the Current State of the PHP Ecosystem
sparkfabrik
 
UX e Web sostenibile (UXday 2023).pdf
UX e Web sostenibile (UXday 2023).pdfUX e Web sostenibile (UXday 2023).pdf
UX e Web sostenibile (UXday 2023).pdf
sparkfabrik
 
Drupal Dev Days Vienna 2023 - What is the secure software supply chain and th...
Drupal Dev Days Vienna 2023 - What is the secure software supply chain and th...Drupal Dev Days Vienna 2023 - What is the secure software supply chain and th...
Drupal Dev Days Vienna 2023 - What is the secure software supply chain and th...
sparkfabrik
 
Deep dive nella supply chain della nostra infrastruttura cloud
Deep dive nella supply chain della nostra infrastruttura cloudDeep dive nella supply chain della nostra infrastruttura cloud
Deep dive nella supply chain della nostra infrastruttura cloud
sparkfabrik
 
KCD Italy 2022 - Application driven infrastructure with Crossplane
KCD Italy 2022 - Application driven infrastructure with CrossplaneKCD Italy 2022 - Application driven infrastructure with Crossplane
KCD Italy 2022 - Application driven infrastructure with Crossplane
sparkfabrik
 
Come Drupal costruisce le tue pagine
Come Drupal costruisce le tue pagineCome Drupal costruisce le tue pagine
Come Drupal costruisce le tue pagine
sparkfabrik
 
Drupal 10: un framework PHP di sviluppo Cloud Native moderno
Drupal 10: un framework PHP di sviluppo Cloud Native modernoDrupal 10: un framework PHP di sviluppo Cloud Native moderno
Drupal 10: un framework PHP di sviluppo Cloud Native moderno
sparkfabrik
 
Do you know what your Drupal is doing Observe it! (DrupalCon Prague 2022)
Do you know what your Drupal is doing Observe it! (DrupalCon Prague 2022)Do you know what your Drupal is doing Observe it! (DrupalCon Prague 2022)
Do you know what your Drupal is doing Observe it! (DrupalCon Prague 2022)
sparkfabrik
 
Do you know what your Drupal is doing_ Observe it!
Do you know what your Drupal is doing_ Observe it!Do you know what your Drupal is doing_ Observe it!
Do you know what your Drupal is doing_ Observe it!
sparkfabrik
 
Progettare e sviluppare soluzioni serverless con AWS
Progettare e sviluppare soluzioni serverless con AWSProgettare e sviluppare soluzioni serverless con AWS
Progettare e sviluppare soluzioni serverless con AWS
sparkfabrik
 
From React to React Native - Things I wish I knew when I started
From React to React Native - Things I wish I knew when I startedFrom React to React Native - Things I wish I knew when I started
From React to React Native - Things I wish I knew when I started
sparkfabrik
 
Ad

Recently uploaded (20)

Who Watches the Watchmen (SciFiDevCon 2025)
Who Watches the Watchmen (SciFiDevCon 2025)Who Watches the Watchmen (SciFiDevCon 2025)
Who Watches the Watchmen (SciFiDevCon 2025)
Allon Mureinik
 
Pixologic ZBrush Crack Plus Activation Key [Latest 2025] New Version
Pixologic ZBrush Crack Plus Activation Key [Latest 2025] New VersionPixologic ZBrush Crack Plus Activation Key [Latest 2025] New Version
Pixologic ZBrush Crack Plus Activation Key [Latest 2025] New Version
saimabibi60507
 
Automation Techniques in RPA - UiPath Certificate
Automation Techniques in RPA - UiPath CertificateAutomation Techniques in RPA - UiPath Certificate
Automation Techniques in RPA - UiPath Certificate
VICTOR MAESTRE RAMIREZ
 
Douwan Crack 2025 new verson+ License code
Douwan Crack 2025 new verson+ License codeDouwan Crack 2025 new verson+ License code
Douwan Crack 2025 new verson+ License code
aneelaramzan63
 
Requirements in Engineering AI- Enabled Systems: Open Problems and Safe AI Sy...
Requirements in Engineering AI- Enabled Systems: Open Problems and Safe AI Sy...Requirements in Engineering AI- Enabled Systems: Open Problems and Safe AI Sy...
Requirements in Engineering AI- Enabled Systems: Open Problems and Safe AI Sy...
Lionel Briand
 
Microsoft AI Nonprofit Use Cases and Live Demo_2025.04.30.pdf
Microsoft AI Nonprofit Use Cases and Live Demo_2025.04.30.pdfMicrosoft AI Nonprofit Use Cases and Live Demo_2025.04.30.pdf
Microsoft AI Nonprofit Use Cases and Live Demo_2025.04.30.pdf
TechSoup
 
Expand your AI adoption with AgentExchange
Expand your AI adoption with AgentExchangeExpand your AI adoption with AgentExchange
Expand your AI adoption with AgentExchange
Fexle Services Pvt. Ltd.
 
The Significance of Hardware in Information Systems.pdf
The Significance of Hardware in Information Systems.pdfThe Significance of Hardware in Information Systems.pdf
The Significance of Hardware in Information Systems.pdf
drewplanas10
 
Meet the Agents: How AI Is Learning to Think, Plan, and Collaborate
Meet the Agents: How AI Is Learning to Think, Plan, and CollaborateMeet the Agents: How AI Is Learning to Think, Plan, and Collaborate
Meet the Agents: How AI Is Learning to Think, Plan, and Collaborate
Maxim Salnikov
 
Not So Common Memory Leaks in Java Webinar
Not So Common Memory Leaks in Java WebinarNot So Common Memory Leaks in Java Webinar
Not So Common Memory Leaks in Java Webinar
Tier1 app
 
LEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRY
LEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRYLEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRY
LEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRY
NidaFarooq10
 
Exploring Wayland: A Modern Display Server for the Future
Exploring Wayland: A Modern Display Server for the FutureExploring Wayland: A Modern Display Server for the Future
Exploring Wayland: A Modern Display Server for the Future
ICS
 
Explaining GitHub Actions Failures with Large Language Models Challenges, In...
Explaining GitHub Actions Failures with Large Language Models Challenges, In...Explaining GitHub Actions Failures with Large Language Models Challenges, In...
Explaining GitHub Actions Failures with Large Language Models Challenges, In...
ssuserb14185
 
F-Secure Freedome VPN 2025 Crack Plus Activation New Version
F-Secure Freedome VPN 2025 Crack Plus Activation  New VersionF-Secure Freedome VPN 2025 Crack Plus Activation  New Version
F-Secure Freedome VPN 2025 Crack Plus Activation New Version
saimabibi60507
 
Adobe Illustrator Crack FREE Download 2025 Latest Version
Adobe Illustrator Crack FREE Download 2025 Latest VersionAdobe Illustrator Crack FREE Download 2025 Latest Version
Adobe Illustrator Crack FREE Download 2025 Latest Version
kashifyounis067
 
Revolutionizing Residential Wi-Fi PPT.pptx
Revolutionizing Residential Wi-Fi PPT.pptxRevolutionizing Residential Wi-Fi PPT.pptx
Revolutionizing Residential Wi-Fi PPT.pptx
nidhisingh691197
 
How to Batch Export Lotus Notes NSF Emails to Outlook PST Easily?
How to Batch Export Lotus Notes NSF Emails to Outlook PST Easily?How to Batch Export Lotus Notes NSF Emails to Outlook PST Easily?
How to Batch Export Lotus Notes NSF Emails to Outlook PST Easily?
steaveroggers
 
Secure Test Infrastructure: The Backbone of Trustworthy Software Development
Secure Test Infrastructure: The Backbone of Trustworthy Software DevelopmentSecure Test Infrastructure: The Backbone of Trustworthy Software Development
Secure Test Infrastructure: The Backbone of Trustworthy Software Development
Shubham Joshi
 
Top 10 Client Portal Software Solutions for 2025.docx
Top 10 Client Portal Software Solutions for 2025.docxTop 10 Client Portal Software Solutions for 2025.docx
Top 10 Client Portal Software Solutions for 2025.docx
Portli
 
Societal challenges of AI: biases, multilinguism and sustainability
Societal challenges of AI: biases, multilinguism and sustainabilitySocietal challenges of AI: biases, multilinguism and sustainability
Societal challenges of AI: biases, multilinguism and sustainability
Jordi Cabot
 
Who Watches the Watchmen (SciFiDevCon 2025)
Who Watches the Watchmen (SciFiDevCon 2025)Who Watches the Watchmen (SciFiDevCon 2025)
Who Watches the Watchmen (SciFiDevCon 2025)
Allon Mureinik
 
Pixologic ZBrush Crack Plus Activation Key [Latest 2025] New Version
Pixologic ZBrush Crack Plus Activation Key [Latest 2025] New VersionPixologic ZBrush Crack Plus Activation Key [Latest 2025] New Version
Pixologic ZBrush Crack Plus Activation Key [Latest 2025] New Version
saimabibi60507
 
Automation Techniques in RPA - UiPath Certificate
Automation Techniques in RPA - UiPath CertificateAutomation Techniques in RPA - UiPath Certificate
Automation Techniques in RPA - UiPath Certificate
VICTOR MAESTRE RAMIREZ
 
Douwan Crack 2025 new verson+ License code
Douwan Crack 2025 new verson+ License codeDouwan Crack 2025 new verson+ License code
Douwan Crack 2025 new verson+ License code
aneelaramzan63
 
Requirements in Engineering AI- Enabled Systems: Open Problems and Safe AI Sy...
Requirements in Engineering AI- Enabled Systems: Open Problems and Safe AI Sy...Requirements in Engineering AI- Enabled Systems: Open Problems and Safe AI Sy...
Requirements in Engineering AI- Enabled Systems: Open Problems and Safe AI Sy...
Lionel Briand
 
Microsoft AI Nonprofit Use Cases and Live Demo_2025.04.30.pdf
Microsoft AI Nonprofit Use Cases and Live Demo_2025.04.30.pdfMicrosoft AI Nonprofit Use Cases and Live Demo_2025.04.30.pdf
Microsoft AI Nonprofit Use Cases and Live Demo_2025.04.30.pdf
TechSoup
 
Expand your AI adoption with AgentExchange
Expand your AI adoption with AgentExchangeExpand your AI adoption with AgentExchange
Expand your AI adoption with AgentExchange
Fexle Services Pvt. Ltd.
 
The Significance of Hardware in Information Systems.pdf
The Significance of Hardware in Information Systems.pdfThe Significance of Hardware in Information Systems.pdf
The Significance of Hardware in Information Systems.pdf
drewplanas10
 
Meet the Agents: How AI Is Learning to Think, Plan, and Collaborate
Meet the Agents: How AI Is Learning to Think, Plan, and CollaborateMeet the Agents: How AI Is Learning to Think, Plan, and Collaborate
Meet the Agents: How AI Is Learning to Think, Plan, and Collaborate
Maxim Salnikov
 
Not So Common Memory Leaks in Java Webinar
Not So Common Memory Leaks in Java WebinarNot So Common Memory Leaks in Java Webinar
Not So Common Memory Leaks in Java Webinar
Tier1 app
 
LEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRY
LEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRYLEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRY
LEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRY
NidaFarooq10
 
Exploring Wayland: A Modern Display Server for the Future
Exploring Wayland: A Modern Display Server for the FutureExploring Wayland: A Modern Display Server for the Future
Exploring Wayland: A Modern Display Server for the Future
ICS
 
Explaining GitHub Actions Failures with Large Language Models Challenges, In...
Explaining GitHub Actions Failures with Large Language Models Challenges, In...Explaining GitHub Actions Failures with Large Language Models Challenges, In...
Explaining GitHub Actions Failures with Large Language Models Challenges, In...
ssuserb14185
 
F-Secure Freedome VPN 2025 Crack Plus Activation New Version
F-Secure Freedome VPN 2025 Crack Plus Activation  New VersionF-Secure Freedome VPN 2025 Crack Plus Activation  New Version
F-Secure Freedome VPN 2025 Crack Plus Activation New Version
saimabibi60507
 
Adobe Illustrator Crack FREE Download 2025 Latest Version
Adobe Illustrator Crack FREE Download 2025 Latest VersionAdobe Illustrator Crack FREE Download 2025 Latest Version
Adobe Illustrator Crack FREE Download 2025 Latest Version
kashifyounis067
 
Revolutionizing Residential Wi-Fi PPT.pptx
Revolutionizing Residential Wi-Fi PPT.pptxRevolutionizing Residential Wi-Fi PPT.pptx
Revolutionizing Residential Wi-Fi PPT.pptx
nidhisingh691197
 
How to Batch Export Lotus Notes NSF Emails to Outlook PST Easily?
How to Batch Export Lotus Notes NSF Emails to Outlook PST Easily?How to Batch Export Lotus Notes NSF Emails to Outlook PST Easily?
How to Batch Export Lotus Notes NSF Emails to Outlook PST Easily?
steaveroggers
 
Secure Test Infrastructure: The Backbone of Trustworthy Software Development
Secure Test Infrastructure: The Backbone of Trustworthy Software DevelopmentSecure Test Infrastructure: The Backbone of Trustworthy Software Development
Secure Test Infrastructure: The Backbone of Trustworthy Software Development
Shubham Joshi
 
Top 10 Client Portal Software Solutions for 2025.docx
Top 10 Client Portal Software Solutions for 2025.docxTop 10 Client Portal Software Solutions for 2025.docx
Top 10 Client Portal Software Solutions for 2025.docx
Portli
 
Societal challenges of AI: biases, multilinguism and sustainability
Societal challenges of AI: biases, multilinguism and sustainabilitySocietal challenges of AI: biases, multilinguism and sustainability
Societal challenges of AI: biases, multilinguism and sustainability
Jordi Cabot
 

Behaviour Driven Development con Behat & Drupal

  • 1. 1
  • 2. BDD with Behat & Drupal Alessio Piazza Software Developer @SparkFabrik (twinbit + agavee) twitter: @alessiopiazza I do stuff with Drupal SPARKFABRIK
  • 3. 3 • Behaviour Driven Development • a software development process that emerged from TDD (Test Driven Development) • Behaviour driven development specifies that tests of any unit of software should be specified in terms of the desired behaviour of the unit BDD SPARKFABRIK
  • 4. WHY BDD? or TDD? • You must test your application • Save your self from regressions (fix one thing, break another one) • Save your self from misunderstanding between you and your client • Your tests become specification 4 SPARKFABRIK
  • 5. BDD Workflow 1. Write a specification feature 2. Implement its test 3. Run test and watch it FAIL 4. Change your app to make test PASS 5. Run test and watch it PASS 6. Repat from 2-5 until all GREEN 5 SPARKFABRIK
  • 6. BDD: HOW IT WORKS? 6
  • 8. Write a specification feature 8 Feature: Download Drupal 8 In order to use Drupal 8 as a user i should be able to download it from drupal.org Scenario: Download Drupal 8 from Drupal.org Given i am on the homepage When i Click “Download and Extend” Then I should see the link “Download Drupal 8.0.0” Scenario: … SPARKFABRIK
  • 9. SCENARIO STRUCTURE 9 Scenario: Download Drupal 8 from Drupal.org Given I am on drupal.org homepage When I Click “Download and Extend” Then I should see the link “Download Drupal 8.0.0” SPARKFABRIK
  • 10. SCENARIO STRUCTURE 10 Given i am on drupal.org homepage And i Click “Download and Extend” Then I should see the link “Download Drupal 8.0.0” Scenario: Download Drupal 8 from Drupal.org Keyword Description SPARKFABRIK
  • 11. SCENARIO STRUCTURE 11 Given i am on drupal.org homepage And i Click “Download and Extend” Then I should see the link “Download Drupal 8.0.0” Scenario: Download Drupal 8 from Drupal.org Keyword Description Steps Given I am on drupal.org homepage When I Click “Download and Extend” Then I should see the link “Download …” SPARKFABRIK
  • 12. STEPS: Keywords 12 Given -> To put the system in a known state Given I am an anonymous user SPARKFABRIK
  • 13. Given STEPS: Keywords 13 When -> To describe the key action to performs When I click on the link SPARKFABRIK
  • 14. Given STEPS: Keywords 14 When Then -> To to observe outcomes Then I should see the text “Hello” SPARKFABRIK
  • 15. Given STEPS: Keywords 15 When Then And / But -> To make our scenario more readable SPARKFABRIK
  • 16. STEPS: Keywords 16 Scenario: Download Drupal 8 from Drupal.org Given I am on drupal.org homepage Given I am an anonymous user When I Click “Download and Extend” When I Click “Download Drupal 8.0.0” Then I should see the link “Drupal Core 8.0.0” SPARKFABRIK
  • 17. STEPS: Keywords 17 Scenario: Download Drupal 8 from Drupal.org Given I am on drupal.org homepage And I am an anonymous user When I Click “Download and Extend” And I Click “Download Drupal 8.0.0” Then I should see the link “Drupal Core 8.0.0” SPARKFABRIK
  • 18. GHERKIN • It is a Business Readable, Domain Specific Language • Lets you describe software’s behaviour without detailing how that behaviour is implemented. • Gherkin is the language that BEHAT understands. 18 SPARKFABRIK
  • 19. BEHAT docs.behat.org/en/v3.0/ Open source Behavior Driven Development framework for PHP (5.3+) Inspired from Cucumber (Ruby) www.cucumber.io From version 3 BEHAT it’s an official Cucumber implementation in PHP Let us write tests based on our scenarios 19 SPARKFABRIK
  • 20. HOW BEHAT READS GHERKIN? 20 Given I am an anonymous user SPARKFABRIK
  • 21. HOW BEHAT READS GHERKIN? 21 /** * @Given I am an anonymous user */ public function assertAnonymousUser() { // Verify the user is logged out. if ($this->loggedIn()) { $this->logout(); } } Given I am an anonymous user SPARKFABRIK
  • 22. HOW BEHAT READS GHERKIN? 22 Then I should not see the text :text SPARKFABRIK
  • 23. HOW BEHAT READS GHERKIN? 23 /** * @Then I should not see the text :text */ public function assertNotTextVisible($text) { // Use the Mink Extension step definition. $this->assertPageNotContainsText($text); } Then I should not see the text :text SPARKFABRIK
  • 24. STEP RESULTS 24 /** * @Then I should not see the text :text */ public function assertNotTextVisible($text) { // This step will fail. throw new Exception(‘Test failed’); } • A step FAILS when an Exception is thrown SPARKFABRIK
  • 25. STEP RESULTS 25 /** * @Then I will trigger a success */ public function triggerSuccess() { // This step will pass. print(‘Hello DrupalDay’); } • A step PASS when no Exception are raised SPARKFABRIK
  • 26. OTHER STEP RESULTS 26 • SUCCESSFUL • FAILED • PENDING • UNDEFINED • SKIPPED • AMBIGUOUS • REDUNDANT SPARKFABRIK
  • 27. WHERE ARE THESE STEPS? 27 • STEPS are defined inside plain PHP Object classes, called CONTEXTS • MinkContext and DrupalContext give use a lot of pre-defined steps ready to be used • Custom steps can be defined inside FeatureContext class SPARKFABRIK
  • 28. Sum Up 28 Give use the syntax to write features and scenarios Our framework that reads our scenarios and run tests Classes containing our step definitions GHERKIN BEHAT CONTEXTS SPARKFABRIK
  • 29. How we integrate Behat and Drupal? 29 Behat Drupal Extension An integration layer between Drupal and Behat https://www.drupal.org/project/drupalextension https://github.com/jhedstrom/drupalextension SPARKFABRIK
  • 30. From your project root.. composer require drupal/drupal-extension 30 - Installing drupal/drupal-driver (v1.1.4) Downloading: 100% > DrupalCoreComposerComposer::vendorTestCodeCleanup - Installing symfony/filesystem (v3.0.0) Downloading: 100% > DrupalCoreComposerComposer::vendorTestCodeCleanup - Installing symfony/config (v2.8.0) Downloading: 100% > DrupalCoreComposerComposer::vendorTestCodeCleanup - Installing behat/transliterator (v1.1.0) Loading from cache … … > DrupalCoreComposerComposer::vendorTestCodeCleanup - Installing drupal/drupal-extension (v3.1.3) Downloading: 100% SPARKFABRIK
  • 31. Create file behat.yml 31 1 default: 2 suites: 3 default: 4 contexts: 5 - FeatureContext 6 - DrupalDrupalExtensionContextDrupalContext 7 - DrupalDrupalExtensionContextMinkContext 8 extensions: 9 BehatMinkExtension: 10 goutte: ~ 11 base_url: http://d8.drupalday2015.sparkfabrik.loc # Replace with your site's URL 12 DrupalDrupalExtension: 13 blackbox: ~ see https://github.com/jhedstrom/drupalextension SPARKFABRIK
  • 32. Then --init your test suite 32 vendor/bin/behat --init +d features - place your *.feature files here +d features/bootstrap - place your context classes here +f features/bootstrap/FeatureContext.php - place your definitions, transformations and hooks here SPARKFABRIK
  • 34. BROWSER INTERACTION • With BDD we write clear, understandable scenario • Our scenario often describe an interaction with the browser 34 WE NEED A BROWSER EMULATOR SPARKFABRIK
  • 35. BROWSER EMULATORS • Headless browser emulators (Goutte) • Browser controllers (Selenium2, SAHI) • They do basically the same thing: control or emulate browsers but they do them in different ways • They comes with their pro and cons 35 SPARKFABRIK
  • 36. MINK! http://mink.behat.org/en/latest/ • MINK removes API differences between different browser emulators • MINK provides different drivers for every browser emulator • MINK gives you an easy way to 1. control the browser 2. traverse pages 3. manipulate page elements 4. interact with page elements 36 SPARKFABRIK
  • 37. 37 /** * @When /^(?:|I )move forward one page$/ */ public function forward() { $this->getSession()->forward(); } MINK! http://mink.behat.org/en/latest/ When I move forward one page SPARKFABRIK
  • 38. Wrap up 38 GHERKIN BEHAT CONTEXTS MINK Give use the syntax to write features and scenarios Our framework that reads our scenarios and run the tests Classes containing our step definitions Describe browser interaction without worrying about the browser SPARKFABRIK
  • 39. 39