{Behat & BDD} Luis Ribeiro Systems Architect ciandt.com - - PowerPoint PPT Presentation

behat amp bdd
SMART_READER_LITE
LIVE PREVIEW

{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


slide-1
SLIDE 1

ciandt.com

{Behat & BDD}

Luis Ribeiro

Systems Architect

slide-2
SLIDE 2

Presenter

ciandt.com

Luis Ribeiro

> Systems Architect at CI&T > +5Years Drupal experience > Large Open Source experience > Working with ~150 Drupallers

slide-3
SLIDE 3

Why automated tests ?

ciandt.com

slide-4
SLIDE 4

Why automated tests ?

Improve the Speed Test Coverage Efficiency Testers Motivation Less Human Resources

SAVE BIG MONEY

ciandt.com

slide-5
SLIDE 5

BDD – Behavior Driven Development

ciandt.com

slide-6
SLIDE 6

BDD – Behavior Driven Development

ciandt.com

How the customer explained it

slide-7
SLIDE 7

BDD – Behavior Driven Development

ciandt.com

How the project leader understood it

slide-8
SLIDE 8

BDD – Behavior Driven Development

ciandt.com

How the programmer wrote it

slide-9
SLIDE 9

BDD – Behavior Driven Development

ciandt.com

What the customer really need it

slide-10
SLIDE 10

BDD – Behavior Driven Development

ciandt.com

What the testers received

slide-11
SLIDE 11

BDD – Behavior Driven Development

ciandt.com

example-based communication

business and developers can clearly understand

slide-12
SLIDE 12

“How the Individual parts work”

Behat

ciandt.com

slide-13
SLIDE 13

Gherckin

“Defining your behavior”

Behat

ciandt.com

slide-14
SLIDE 14

Gherckin Structure

1- FEATURES 2- SCENARIOS 3- STEPS

Behat

ciandt.com

slide-15
SLIDE 15

ciandt.com

Behat

slide-16
SLIDE 16

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

slide-17
SLIDE 17

ciandt.com

Behat Example

Read news in Portuguese

Feature: Feature: I18n I18n In In order

  • rder 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

slide-18
SLIDE 18

ciandt.com

Behat

slide-19
SLIDE 19

ciandt.com

Behat Example

Feature: Feature: Add Add new new Article Article In In order

  • rder to

to manage manage a a newsletter newsletter As As a a site site site site administrat administrator

  • r

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”

slide-20
SLIDE 20

ciandt.com

slide-21
SLIDE 21

ciandt.com

..is a BDD (behavior driven development) framework for PHP.

Behat

slide-22
SLIDE 22

ciandt.com

How Behat works ?

Behat

maps each step(s) in a PHP Callback

slide-23
SLIDE 23

Behat Setup

ciandt.com

slide-24
SLIDE 24

ciandt.com

Requirements

Behat Requirements

PHP higher than 5.3.5 Libraries installed:

Ø

curl

Ø

mbstring

Ø

xml

slide-25
SLIDE 25

ciandt.com

Behat is a library easily installed using composer

Behat Requirements

slide-26
SLIDE 26

ciandt.com

Behat Setup Step1

1- Create a composer file “composer.json” 2- Add the below lines 3- run the command “composer install”

slide-27
SLIDE 27

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”

slide-28
SLIDE 28

ciandt.com

Behat Setup Step 3 1- run the command “bin/behat -dl”

slide-29
SLIDE 29

ciandt.com

DEMO

slide-30
SLIDE 30

Drupal Extension

ciandt.com

slide-31
SLIDE 31

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

slide-32
SLIDE 32

ciandt.com

Drupal Extension

Drupal Extension Drivers

slide-33
SLIDE 33

ciandt.com

Drupal Extension

Drupal extension .yml examples

slide-34
SLIDE 34

ciandt.com

Drupal Extension

Drupal extension Feature example

slide-35
SLIDE 35

ciandt.com

Drupal Extension

Customizing Behat

slide-36
SLIDE 36

ciandt.com

Drupal Extension

What next ?

slide-37
SLIDE 37

[text]

<Insert here an image> <Insert here an image> Logo

Before Behat = 4 Hours After Behat = 25 minutes

Smoke Test

~ 5 hours

Time spent to learn, setup & start to implement Behat

QA resources reduced from 3 to 1

ciandt.com

slide-38
SLIDE 38

ciandt.com

Final Considerations

1- EASY TO LEARN 2- POWERFULL 3- EXTENSIBLE

slide-39
SLIDE 39

Thank you!

Sources http://behat.org/ http://behat-drupal-extension.readthedocs.io/ Luis Ribeiro luisr@ciandt.com

ciandt.com

slide-40
SLIDE 40

?

ciandt.com