ciandt.com
{Behat & BDD}
Luis Ribeiro
Systems Architect
{Behat & BDD} Luis Ribeiro Systems Architect ciandt.com - - PowerPoint PPT Presentation
{Behat & BDD} Luis Ribeiro Systems Architect ciandt.com Presenter Luis Ribeiro > Systems Architect at CI&T > +5Years Drupal experience > Large Open Source experience > Working with ~150 Drupallers ciandt.com Why
ciandt.com
Luis Ribeiro
Systems Architect
Presenter
ciandt.com
> Systems Architect at CI&T > +5Years Drupal experience > Large Open Source experience > Working with ~150 Drupallers
ciandt.com
Why automated tests ?
Improve the Speed Test Coverage Efficiency Testers Motivation Less Human Resources
ciandt.com
ciandt.com
BDD – Behavior Driven Development
ciandt.com
How the customer explained it
BDD – Behavior Driven Development
ciandt.com
How the project leader understood it
BDD – Behavior Driven Development
ciandt.com
How the programmer wrote it
BDD – Behavior Driven Development
ciandt.com
What the customer really need it
BDD – Behavior Driven Development
ciandt.com
What the testers received
BDD – Behavior Driven Development
ciandt.com
Behat
ciandt.com
Behat
ciandt.com
Behat
ciandt.com
ciandt.com
Behat
ciandt.com
Behat
1- Given Defines the initial state of the system for the scenario 2- When Describes the action taken by the person/role 3- Then Describes the observable system state after the action has been performed 4- And/But Can be added to create multiple Given/When/Then lines
ciandt.com
Behat Example
Feature: Feature: I18n I18n In In order
to read read news news in in portuguese portuguese As As a a Brazilian Brazilian user user I need need to to be be able able to to switch switch locale locale
ciandt.com
Behat
ciandt.com
Behat Example
Feature: Feature: Add Add new new Article Article In In order
to manage manage a a newsletter newsletter As As a a site site site site administrat administrator
I I need need to to be be able able to to add add new new content content Scenario: Scenario: Add Add new new content content for for News News Given Given I I go go to to “http:// “http://ur url/a /admi min/ n/new ews” When When I I click click “New “New Article” Article” And And I I fill fill “Title” “Title” with with “My “My Title” Title” And And I I press press “Save” “Save” Then Then I I should should see see “A “A New New content content was was added” added”
ciandt.com
ciandt.com
Behat
ciandt.com
Behat
ciandt.com
ciandt.com
Behat Requirements
PHP higher than 5.3.5 Libraries installed:
Ø
curl
Ø
mbstring
Ø
xml
ciandt.com
Behat Requirements
ciandt.com
Behat Setup Step1
1- Create a composer file “composer.json” 2- Add the below lines 3- run the command “composer install”
ciandt.com
Behat Setup Step 2
1- Create a configuration file called “behat.yml” 2- Add the below lines 3- run the command “bin/behat --init”
ciandt.com
Behat Setup Step 3 1- run the command “bin/behat -dl”
ciandt.com
ciandt.com
ciandt.com
Drupal Extension
1- Set up test data with Drush or the Drupal API 2- Define theme regions and test data appears within them 3- Clear the cache, log out, and other useful steps 4- Detect and discover steps provided by contributed modules and themes
Drupal Specific Functionalities for BDD using Behat and Mink
ciandt.com
Drupal Extension
Drupal Extension Drivers
ciandt.com
Drupal Extension
Drupal extension .yml examples
ciandt.com
Drupal Extension
Drupal extension Feature example
ciandt.com
Drupal Extension
ciandt.com
Drupal Extension
[text]
<Insert here an image> <Insert here an image> Logo
Before Behat = 4 Hours After Behat = 25 minutes
Smoke Test
Time spent to learn, setup & start to implement Behat
ciandt.com
ciandt.com
Final Considerations
Sources http://behat.org/ http://behat-drupal-extension.readthedocs.io/ Luis Ribeiro luisr@ciandt.com
ciandt.com
ciandt.com