{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 automated tests ? ciandt.com
Why automated tests ? Improve the Speed Test Coverage Efficiency Testers Motivation Less Human Resources SAVE BIG MONEY ciandt.com
BDD – Behavior Driven Development ciandt.com
BDD – Behavior Driven Development How the customer explained it ciandt.com
BDD – Behavior Driven Development How the project leader understood it ciandt.com
BDD – Behavior Driven Development How the programmer wrote it ciandt.com
BDD – Behavior Driven Development What the customer really need it ciandt.com
BDD – Behavior Driven Development What the testers received ciandt.com
BDD – Behavior Driven Development example-based communication business and developers can clearly understand ciandt.com
Behat “How the Individual parts work” ciandt.com
Behat Gherckin “Defining your behavior” ciandt.com
Behat Gherckin Structure 1- FEATURES 2- SCENARIOS 3- STEPS 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 Read news in Portuguese Feature: Feature: I18n I18n In In order order to 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 order In order to to manage manage a a newsletter newsletter As As a a site site site site administrat administrator or 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 News for News Given I Given 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 I And 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 added” was added” ciandt.com
ciandt.com
Behat ..is a BDD (behavior driven development) framework for PHP. ciandt.com
Behat How Behat works ? maps each step(s) in a PHP Callback ciandt.com
Behat Setup ciandt.com
Behat Requirements Requirements PHP higher than 5.3.5 Libraries installed: curl Ø mbstring Ø xml Ø ciandt.com
Behat Requirements Behat is a library easily installed using composer 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
DEMO ciandt.com
Drupal Extension 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 Drupal Specific contributed modules and themes 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 Customizing Behat ciandt.com
Drupal Extension What next ? ciandt.com
Smoke Test Time spent to learn, setup & Logo start to implement Behat Before Behat = 4 Hours ~ 5 hours After Behat = 25 minutes <Insert here an image> <Insert here an image> QA resources reduced [text] from 3 to 1 ciandt.com
Final Considerations 1- EASY TO LEARN 2- POWERFULL 3- EXTENSIBLE ciandt.com
Thank you! Sources http://behat.org/ http://behat-drupal-extension.readthedocs.io/ Luis Ribeiro luisr@ciandt.com ciandt.com
? ciandt.com
Recommend
More recommend