Slide 1

Slide 1 text

using BDD How to make your clients happy

Slide 2

Slide 2 text

AM who i @everzet senior from-birth web developer in

Slide 3

Slide 3 text

Agile mentor in KnpLabs since 2011 BDD evangelist Creator of Behat, Mink Contributor to Symfony2 framework [email protected] http://github.com/everzet http://card.everzet.com AM who i @everzet senior from-birth web developer in

Slide 4

Slide 4 text

What’s our primary job ?

Slide 5

Slide 5 text

to make our clients happy !

Slide 6

Slide 6 text

Current state:

Slide 7

Slide 7 text

more awesome languages

Slide 8

Slide 8 text

more awesome frameworks

Slide 9

Slide 9 text

more awesome developers http://www.flickr.com/photos/officialgdc/4421337520

Slide 10

Slide 10 text

clients happiness = ?

Slide 11

Slide 11 text

No content

Slide 12

Slide 12 text

clients happiness =valuable product

Slide 13

Slide 13 text

awesome languages ≠valuable product

Slide 14

Slide 14 text

awesome languages frameworks ≠valuable product

Slide 15

Slide 15 text

awesome languages frameworks developers ≠valuable product

Slide 16

Slide 16 text

awesome valuable ≉

Slide 17

Slide 17 text

= valuable product

Slide 18

Slide 18 text

popular = valuable product

Slide 19

Slide 19 text

popular useful = valuable product

Slide 20

Slide 20 text

popular useful profitable = valuable product

Slide 21

Slide 21 text

BUT

Slide 22

Slide 22 text

How to bring value into client product ?

Slide 23

Slide 23 text

especially, when client doesn’t know that he needs it

Slide 24

Slide 24 text

By asking

Slide 25

Slide 25 text

http://www.flickr.com/photos/brendio/71252025

Slide 26

Slide 26 text

Client wants internationalization?

Slide 27

Slide 27 text

http://www.flickr.com/photos/editor/6698208975

Slide 28

Slide 28 text

Client wants authorization?

Slide 29

Slide 29 text

http://www.flickr.com/photos/quinnanya/3588989219

Slide 30

Slide 30 text

Client wants this new shiny awesome feature?

Slide 31

Slide 31 text

Well, you got it....

Slide 32

Slide 32 text

COMMUNICATIONS photo by joshfassbind.com

Slide 33

Slide 33 text

How does it helps?

Slide 34

Slide 34 text

Correct answers to WHY? helps you to bring higher priority on things, that really matter

Slide 35

Slide 35 text

How does the correct answer looks like? WHY?

Slide 36

Slide 36 text

No content

Slide 37

Slide 37 text

Correct WHY? answer should point out:

Slide 38

Slide 38 text

Correct WHY? answer should point out: • Added value of the feature

Slide 39

Slide 39 text

Correct WHY? answer should point out: • Added value of the feature • Benefitiar of the feature

Slide 40

Slide 40 text

In order to see top users

Slide 41

Slide 41 text

In order to see top users As a visitor

Slide 42

Slide 42 text

In order to see top users As a visitor I need to be able to sort them by rating

Slide 43

Slide 43 text

In order to see top users As a visitor I need to be able to sort them by rating

Slide 44

Slide 44 text

In order to get latest news As a visitor I need to be able to see last 3 articles on homepage In order to see top users As a visitor I need to be able to sort them by rating

Slide 45

Slide 45 text

In order to spend my money As a user I need to be able to buy rating on site In order to get latest news As a visitor I need to be able to see last 3 articles on homepage In order to see top users As a visitor I need to be able to sort them by rating

Slide 46

Slide 46 text

X - the benefit or value of the feature Y - the person (or role) who will benefit Z - some feature In order to [X] As a [Y] I need [Z] Its strength is that it forces you to identify the value of delivering a story when you first define it. © Dan North ❤ of BDD

Slide 47

Slide 47 text

In order to spend my money As a user I need to be able to buy rating on site In order to get latest news As a visitor I need to be able to see last 3 articles on homepage In order to see top users As a visitor I need to be able to sort them by rating

Slide 48

Slide 48 text

2 1 3 In order to spend my money As a user I need to be able to buy rating on site In order to get latest news As a visitor I need to be able to see last 3 articles on homepage In order to see top users As a visitor I need to be able to sort them by rating define priorities

Slide 49

Slide 49 text

In order to [X] As a [Y] I need [Z]

Slide 50

Slide 50 text

Hey, it looks like a user story!

Slide 51

Slide 51 text

In order to [X] As a [Y] I need [Z] UserStory: it IS

Slide 52

Slide 52 text

Given some initial context (the givens), When an event occurs, Then ensure some outcomes. In order to [X] As a [Y] I need [Z] UserStory:

Slide 53

Slide 53 text

Given some initial context (the givens), When an event occurs, Then ensure some outcomes. In order to [X] As a [Y] I need [Z] Given some initial context (the givens), When an event occurs, Then ensure some outcomes. UserStory:

Slide 54

Slide 54 text

In order to [X] As a [Y] I need [Z] Scenario 1: Scenario 2: Given some initial context (the givens), When an event occurs, Then ensure some outcomes. Given some initial context (the givens), When an event occurs, Then ensure some outcomes. UserStory:

Slide 55

Slide 55 text

A story’s behaviour is simply its acceptance criteria! - if the system fulfills all the acceptance criteria, it’s behaving correctly; if it doesn’t, it isn’t.

Slide 56

Slide 56 text

Acceptance criteria could be automated!

Slide 57

Slide 57 text

No content

Slide 58

Slide 58 text

In order to ... As a ... I need ... Scenario: 1st scenario title Scenario: 2nd scenario title Feature: Feature description Given some initial context (the givens) When an event occurs Then ensure some outcomes Given some initial context (the givens) When an event occurs Then ensure some outcomes

Slide 59

Slide 59 text

1. feature 2. scenario 3. step ... ... 2. scenario 3. step ... ... Given some initial context (the givens) When an event occurs Then ensure some outcomes In order to ... As a ... I need ... Given some initial context (the givens) When an event occurs Then ensure some outcomes Scenario: 1st scenario title Scenario: 2nd scenario title Feature: Feature description feature tree

Slide 60

Slide 60 text

Given('/^I have a bank account$/', function($world) { $world->account = new BankAccount(); } ); Given I have a bank account

Slide 61

Slide 61 text

Given('/^I have a bank account$/', function($world) { $world->account = new BankAccount(); } ); When('/^I deposit (\d+)\$$/', function($world, $dollars) { $world->account->deposit($dollars); } ); Given I have a bank account When I deposit 35$

Slide 62

Slide 62 text

Then I should have 35$

Slide 63

Slide 63 text

Then I should have 35$ Then('/^I should have (\d+)\$$/', function($world, $balance) { if ($balance !== $world->account->getBalance()) { throw new \Exception('Wrong balance!'); } } );

Slide 64

Slide 64 text

Given('/^I have a bank account$/', function($world) { $world->account = new BankAccount(); } ); $steps->When('/^I deposit (\d+)\$$/', function($world, $dollars) { $world->account->deposit($dollars); } ); $steps->Then('/^I should have (\d+)\$$/', function($world, $balance) { assertEquals($balance, $world->account->getBalance()); } );

Slide 65

Slide 65 text

Feature: User logins

Slide 66

Slide 66 text

In order to have extended abilities As a site user I need to be able to login Feature: User logins

Slide 67

Slide 67 text

In order to have extended abilities As a site user I need to be able to login Scenario: Existing user can login Feature: User logins

Slide 68

Slide 68 text

In order to have extended abilities As a site user I need to be able to login Scenario: Existing user can login Scenario: Non-existing user can’t login Feature: User logins

Slide 69

Slide 69 text

Given a site have “everzet” user with “qwerty” password And I am on the “/login” When I fill in “username” with “everzet” And I fill in “password” with “qwerty” And I press “login” in login form Then I should see “Welcome, everzet” In order to have extended abilities As a site user I need to be able to login Scenario: Existing user can login Given a site have “everzet” user with “qwerty” password And I am on the “/login” When I fill in “username” with “someone” And I fill in “password” with “qwerty” And I press “login” in login form Then I should see “Login or password is incorrect” Scenario: Non-existing user can’t login Feature: User logins

Slide 70

Slide 70 text

Given a site have “everzet” user with “qwerty” password And I am on the “/login” When I fill in “username” with “everzet” And I fill in “password” with “qwerty” And I press “login” in login form Then I should see “Welcome, everzet” In order to have extended abilities As a site user I need to be able to login Scenario: Existing user can login Given a site have “everzet” user with “qwerty” password And I am on the “/login” When I fill in “username” with “someone” And I fill in “password” with “qwerty” And I press “login” in login form Then I should see “Login or password is incorrect” Scenario: Non-existing user can’t login Feature: User logins

Slide 71

Slide 71 text

Given I am on the “/login” page When I fill in “username” with “everzet” And I fill in “password” with “qwerty” And I press “login” in login form Then I should see “Welcome, everzet” In order to have extended abilities As a site user I need to be able to login Scenario: Existing user can login Given I am on the “/login” page When I fill in “username” with “someone” And I fill in “password” with “qwerty” And I press “login” in login form Then I should see “Login or password is incorrect” Scenario: Non-existing user can’t login Feature: User logins

Slide 72

Slide 72 text

Given I am on the “/login” page When I fill in “username” with “everzet” And I fill in “password” with “qwerty” And I press “login” in login form Then I should see “Welcome, everzet” In order to have extended abilities As a site user I need to be able to login Scenario: Existing user can login Given a site have “everzet” user with “qwerty” password Background: Given I am on the “/login” page When I fill in “username” with “someone” And I fill in “password” with “qwerty” And I press “login” in login form Then I should see “Login or password is incorrect” Scenario: Non-existing user can’t login Feature: User logins

Slide 73

Slide 73 text

Given I am on the “/login” page When I fill in “username” with “everzet” And I fill in “password” with “qwerty” And I press “login” in login form Then I should see “Welcome, everzet” In order to have extended abilities As a site user I need to be able to login Scenario: Existing user can login Given a site have users: Background: Given I am on the “/login” page When I fill in “username” with “someone” And I fill in “password” with “qwerty” And I press “login” in login form Then I should see “Login or password is incorrect” Scenario: Non-existing user can’t login | username | password | | everzet | qwerty | Feature: User logins

Slide 74

Slide 74 text

Given I am on the “/login” page When I fill in “username” with “” And I fill in “password” with “” And I press “login” in login form Then I should see “” In order to have extended abilities As a site user I need to be able to login Scenario Outline: Only existing users can login Given a site have users: Background: | username | password | | everzet | qwerty | Feature: User logins

Slide 75

Slide 75 text

Given I am on the “/login” page When I fill in “username” with “” And I fill in “password” with “” And I press “login” in login form Then I should see “” In order to have extended abilities As a site user I need to be able to login Scenario Outline: Only existing users can login Given a site have users: Background: | username | password | | everzet | qwerty | Examples: Feature: User logins

Slide 76

Slide 76 text

Given I am on the “/login” page When I fill in “username” with “” And I fill in “password” with “” And I press “login” in login form Then I should see “” In order to have extended abilities As a site user I need to be able to login Scenario Outline: Only existing users can login Feature: User logins Given a site have users: Background: | username | password | | everzet | qwerty | Examples: | username | password | message | | everzet | qwerty | Welcome, everzet | | someone | pa$$word | Login or password is incorrect |

Slide 77

Slide 77 text

In-browser testing and frameworks support

Slide 78

Slide 78 text

Sahi Goutte Selenium sfBrowser Symfony2 Client

Slide 79

Slide 79 text

Sahi Goutte Selenium sfBrowser Symfony2 Client through one clean API

Slide 80

Slide 80 text

M!"#

Slide 81

Slide 81 text

Given I am on the “/login” page When I fill in “username” with “” And I fill in “password” with “” And I press “login” in login form Then I should see “” In order to have extended abilities As a site user I need to be able to login Scenario Outline: Only existing users can login Feature: User logins Given a site have users: Background: | username | password | | everzet | qwerty | Examples: | username | password | message | | everzet | qwerty | Welcome, everzet | | someone | pa$$word | Login or password is incorrect |

Slide 82

Slide 82 text

Given I am on the “/login” page When I fill in “username” with “” And I fill in “password” with “” And I press “login” in login form Then I should see “” In order to have extended abilities As a site user I need to be able to login Scenario Outline: Only existing users can login Feature: User logins Given a site have users: Background: | username | password | | everzet | qwerty | Examples: | username | password | message | | everzet | qwerty | Welcome, everzet | | someone | pa$$word | Login or password is incorrect | @javascript

Slide 83

Slide 83 text

Questions?