Slide 1

Slide 1 text

B!"#$ b y e x a m p l e B!"#$

Slide 2

Slide 2 text

@everzet Konstantin Kudryashov

Slide 3

Slide 3 text

This talk is not about: • how to setup Behat, Mink, *Extension • how to write your FeatureContext’s This talk is all about: • how to fix communications between you and your clients with StoryBDD • how to build successful products by concentrating on real business values • how to become a real Behat pro

Slide 4

Slide 4 text

Behavior Driven Development

Slide 5

Slide 5 text

Behavior Driven Development 5.3+

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

1st commit 2010-06-30

Slide 8

Slide 8 text

1st commit 2010-06-30 30 june - 2y

Slide 9

Slide 9 text

Some projects already using

Slide 10

Slide 10 text

Some projects thinking just

Slide 11

Slide 11 text

Some users comparing are

Slide 12

Slide 12 text

Some comparing are users

Slide 13

Slide 13 text

” I would never have imagined that Behat and Mink were going to even compare to Cucumber and Capybara, but it does!! Brett Scott lead web developer @ bbc.com

Slide 14

Slide 14 text

Is Behat awesome Functional testing Framework ?

Slide 15

Slide 15 text

You

Slide 16

Slide 16 text

are

Slide 17

Slide 17 text

Wrong!

Slide 18

Slide 18 text

It is awesome, but is it Functional testing Framework ?

Slide 19

Slide 19 text

It is awesome, but is it Functional testing Framework ?

Slide 20

Slide 20 text

NO, it s NOT

Slide 21

Slide 21 text

We are not testing that application functions as we (developers) expect it to, but instead we’re testing that it fullfils clients business needs.

Slide 22

Slide 22 text

Some applications could easily fullfill developers expectations and still not being able to cover business needs.

Slide 23

Slide 23 text

You might think about Behat as a tool to teach your clients about testing, but in reality it's a tool to teach you about client business.

Slide 24

Slide 24 text

Exploration OF Domain area

Slide 25

Slide 25 text

3 levels of domain exploration

Slide 26

Slide 26 text

1 2 3 narrative possible scenarios scenario details

Slide 27

Slide 27 text

Feature: Authorization In order to get access to the shopping history As a frequent buyer I need to be able to authenticate 1 2 3 possible scenarios scenario details

Slide 28

Slide 28 text

Feature: Authorization In order to get access to the shopping history As a frequent buyer I need to be able to authenticate Scenario: Successfully authenticating with correct credentials 1 2 3 scenario details

Slide 29

Slide 29 text

Feature: Authorization In order to get access to the shopping history As a frequent buyer I need to be able to authenticate Scenario: Successfully authenticating with correct credentials Given there is a user “everzet” with password “123” And I am on the login page When I fill in “username” with “everzet” And I fill in “password” with “123” And I press “login” Then I should see “Hello, everzet” 1 2 3

Slide 30

Slide 30 text

Feature: Authorization In order to get access to the shopping history As a frequent buyer I need to be able to authenticate Scenario: Successfully authenticating with correct credentials Scenario: Can not authenticate with wrong credentials Scenario: Blocked user can not authenticate, even with correct credentials

Slide 31

Slide 31 text

Feature: Authorization In order to get access to the shopping history As a frequent buyer I need to be able to authenticate user story =>

Slide 32

Slide 32 text

StoryBDD helps ensuring that development team has understanding of business on the same level that client does

Slide 33

Slide 33 text

StoryBDD helps ensuring that development team has understanding of business on the same level that client does And even leveling up client knowledge of his business

Slide 34

Slide 34 text

How?

Slide 35

Slide 35 text

by Forcing you business questions to answer

Slide 36

Slide 36 text

1. For who?

Slide 37

Slide 37 text

1. For who? 2. What?

Slide 38

Slide 38 text

1. For who? 2. What? 3. How?

Slide 39

Slide 39 text

1. For who? 2. What? 3. How? Why?

Slide 40

Slide 40 text

‘NuFF SAID

Slide 41

Slide 41 text

case #1 About Registration

Slide 42

Slide 42 text

” I want visitors to be able to register on my website through simple registration form. Your hypothetical client

Slide 43

Slide 43 text

1.Who?

Slide 44

Slide 44 text

1.Who? users?

Slide 45

Slide 45 text

1.Who? users visitors

Slide 46

Slide 46 text

1.Who? users visitors 2.Why?

Slide 47

Slide 47 text

1.Who? users visitors 2.Why? it’s common?

Slide 48

Slide 48 text

1.Who? users visitors 2.Why? it’s common buyings history

Slide 49

Slide 49 text

Know your client clients!

Slide 50

Slide 50 text

in order to maintain my shopping history as a site visitor i need to be able to register on this site

Slide 51

Slide 51 text

in order to maintain my shopping history as a site visitor i need to be able to register on this site Feature: registration

Slide 52

Slide 52 text

in order to maintain my shopping history as a site visitor i need to be able to register on this site Feature: registration benefit role (benefitiar)

Slide 53

Slide 53 text

in order to maintain my shopping history as a site visitor i need to be able to register on this site Feature: registration benefit role (benefitiar) in order to ... as a ... i need to ... Feature: ... benefit role (benefitiar) in order to ... as a ... i need to ... Feature: ... benefit role (benefitiar) in order to ... as a ... i need to ... Feature: ... benefit role (benefitiar)

Slide 54

Slide 54 text

in order to ... as a ... i need to ... Feature: ... benefit role (benefitiar) in order to ... as a ... i need to ... Feature: ... benefit role (benefitiar) in order to ... as a ... i need to ... Feature: ... benefit role (benefitiar) in order to maintain my shopping history as a site visitor i need to be able to register on this site Feature: registration benefit role (benefitiar) SELECT f.* FROM ‘/features’ as f ORDER BY f.role, f.benefit LIMIT 10 PSEUDOAgileQL

Slide 55

Slide 55 text

Use gained knowledge!

Slide 56

Slide 56 text

in order to maintain my shopping history as a site visitor i need to be able to register on this site Feature: registration

Slide 57

Slide 57 text

in order to maintain my shopping history as a site visitor i need to be able to register on this site Feature: registration Scenario: Successful registration when visitor provides all the required info

Slide 58

Slide 58 text

in order to maintain my shopping history as a site visitor i need to be able to register on this site Feature: registration Scenario: Successful registration when visitor provides all the required info Scenario: Unable to register when visitor misses required info

Slide 59

Slide 59 text

in order to maintain my shopping history as a site visitor i need to be able to register on this site Feature: registration Scenario: Successful registration when visitor provides all the required info Scenario: Unable to register when visitor misses required info Scenario: ...

Slide 60

Slide 60 text

in order to maintain my shopping history as a site visitor i need to be able to register on this site Feature: registration Scenario: Successful registration when visitor provides all the required info Scenario: Unable to register when visitor misses required info Scenario: ... Scenario: ... Scenario: ... Scenario: ... Scenario: ...

Slide 61

Slide 61 text

in order to maintain my shopping history as a site visitor i need to be able to register on this site Feature: registration Scenario: Successful registration when visitor provides all the required info Given I am on “/register” When I fill in “email” with “[email protected]” And I fill in “username” with “linkedin” And I fill in “password” with “sha1_without_salt” And I press “register” Then the response code should be 200 And the url should be “/”

Slide 62

Slide 62 text

in order to maintain my shopping history as a site visitor i need to be able to register on this site Feature: registration Scenario: Successful registration when visitor provides all the required info Given I am on “/register” When I fill in “email” with “[email protected]” And I fill in “username” with “linkedin” And I fill in “password” with “sha1_without_salt” And I press “register” Then the response code should be 200 And the url should be “/”

Slide 63

Slide 63 text

in order to maintain my shopping history as a site visitor i need to be able to register on this site Feature: registration Scenario: Successful registration when visitor provides all the required info Given I am on “/register” When I fill in “email” with “[email protected]” And I fill in “username” with “linkedin” And I fill in “password” with “sha1_without_salt” And I press “register” Then the response code should be 200 And the url should be “/” ?

Slide 64

Slide 64 text

in order to maintain my shopping history as a site visitor i need to be able to register on this site Feature: registration Scenario: Successful registration when visitor provides all the required info Given I am on homepage And I follow “sign up” When I fill in “email” with “[email protected]” And I fill in “username” with “linkedin” And I fill in “password” with “sha1_without_salt” And I press “register” Then the response code should be 200 And I should be on homepage

Slide 65

Slide 65 text

in order to maintain my shopping history as a site visitor i need to be able to register on this site Feature: registration Scenario: Successful registration when visitor provides all the required info Given I am on homepage And I follow “sign up” When I fill in “email” with “[email protected]” And I fill in “username” with “linkedin” And I fill in “password” with “sha1_without_salt” And I press “register” Then the response code should be 200 And I should be on homepage

Slide 66

Slide 66 text

in order to maintain my shopping history as a site visitor i need to be able to register on this site Feature: registration Scenario: Successful registration when visitor provides all the required info Given I am on homepage And I follow “sign up” When I fill in “email” with “[email protected]” And I fill in “username” with “linkedin” And I fill in “password” with “sha1_without_salt” And I press “register” Then I should see “You have been successfully registered” And I should be on homepage

Slide 67

Slide 67 text

in order to maintain my shopping history as a site visitor i need to be able to register on this site Feature: registration Scenario: Successful registration when visitor provides all the required info Given I am on homepage And I follow “sign up” When I fill in “email” with “[email protected]” And I fill in “username” with “linkedin” And I fill in “password” with “sha1_without_salt” And I press “register” Then I should see “You have been successfully registered” And I should be on homepage

Slide 68

Slide 68 text

case #2 About Sending Emails

Slide 69

Slide 69 text

” I want my users to be able to send feedback messages through contact form. Your hypothetical client

Slide 70

Slide 70 text

1.Who?

Slide 71

Slide 71 text

1.Who? users

Slide 72

Slide 72 text

1.Who? users 2.Why?

Slide 73

Slide 73 text

1.Who? users 2.Why? to give feedback

Slide 74

Slide 74 text

in order to give feedback as a site user i need to be able to use contact form

Slide 75

Slide 75 text

in order to give feedback as a site user i need to be able to use contact form Feature: contact form

Slide 76

Slide 76 text

Scenario: Successfuly sending feedback through a contact form in order to give feedback as a site user i need to be able to use contact form Feature: contact form

Slide 77

Slide 77 text

in order to give feedback as a site user i need to be able to use contact form Feature: contact form Scenario: Successfuly sending feedback through a contact form Given I am on homepage And I follow “sign up” When I fill in “email” with “[email protected]” And I fill in “username” with “linkedin” And I fill in “password” with “sha1_without_salt” And I press “register” Given I am on homepage And I follow “contact-us” And I do not follow redirects When I fill in “text” with “hello, guys” And I press “send” Then email with the subject “feedback” should have been sent And I should be redirected And I should see “message sent” inside “.notifications > p:first-child”

Slide 78

Slide 78 text

in order to give feedback as a site user i need to be able to use contact form Feature: contact form Scenario: Successfuly sending feedback through a contact form Given I am on homepage And I follow “sign up” When I fill in “email” with “[email protected]” And I fill in “username” with “linkedin” And I fill in “password” with “sha1_without_salt” And I press “register” Given I am on homepage And I follow “contact-us” And I do not follow redirects When I fill in “text” with “hello, guys” And I press “send” Then email with the subject “feedback” should have been sent And I should be redirected And I should see “message sent” inside “.notifications > p:first-child” This text is a very boring text and I bet you will not manage to read the whole text since the only period in the text is the one that ends the whole text that is by the way so long and pointless that writing it is just as fun as the text becomes boring since it is so long and pointless and also quite boring since it does not happen a single thing the whole time it is going on which is very long so you will probably not even manage reading to this point which is somewhere halfway and yet you do incredibly as it is since you are reading these words in this long and boring text where nothing happens at all but you will probably stop reading soon as it is just too boring and long and pointless and I notice you are still reading my boring text and wonder how you can withstand it since it is so long and boring plus there is more fun things to do that I would prefer to do rather than reading this soulless text that is really damn boring and now even I am starting to get tired of it so now I am cutting it out. http://sou1forged.deviantart.com/art/Long-and-pointless-text-87288835

Slide 79

Slide 79 text

in order to give feedback as a site user i need to be able to use contact form Feature: contact form Scenario: Successfuly sending feedback through a contact form Given I am on homepage And I follow “sign up” When I fill in “email” with “[email protected]” And I fill in “username” with “linkedin” And I fill in “password” with “sha1_without_salt” And I press “register” Given I am on homepage And I follow “contact-us” And I do not follow redirects When I fill in “text” with “hello, guys” And I press “send” Then email with the subject “feedback” should have been sent And I should be redirected And I should see “message sent” inside “.notifications > p:first-child”

Slide 80

Slide 80 text

in order to give feedback as a site user i need to be able to use contact form Feature: contact form Scenario: Successfuly sending feedback through a contact form Given I am on homepage And I follow “sign up” And I fill in “email” with “[email protected]” And I fill in “username” with “linkedin” And I fill in “password” with “sha1_without_salt” And I press “register” And I am on homepage When I follow “contact-us” And I do not follow redirects And I fill in “text” with “hello, guys” And I press “send” Then email with the subject “feedback” should have been sent And I should be redirected And I should see “message sent” inside “.notifications > p:first-child”

Slide 81

Slide 81 text

in order to give feedback as a site user i need to be able to use contact form Feature: contact form Scenario: Successfuly sending feedback through a contact form Given I am on homepage And I follow “sign up” And I fill in “email” with “[email protected]” And I fill in “username” with “linkedin” And I fill in “password” with “sha1_without_salt” And I press “register” And I am on homepage When I follow “contact-us” And I do not follow redirects And I fill in “text” with “hello, guys” And I press “send” Then email with the subject “feedback” should have been sent And I should be redirected And I should see “message sent” inside “.notifications > p:first-child”

Slide 82

Slide 82 text

in order to give feedback as a site user i need to be able to use contact form Feature: contact form Scenario: Successfuly sending feedback through a contact form Given I am registered user And I am on homepage When I follow “contact-us” And I do not follow redirects And I fill in “text” with “hello, guys” And I press “send” Then email with the subject “feedback” should have been sent And I should be redirected And I should see “message sent” inside “.notifications > p:first-child”

Slide 83

Slide 83 text

in order to give feedback as a site user i need to be able to use contact form Feature: contact form Scenario: Successfuly sending feedback through a contact form Given I am registered user And I am on homepage When I follow “contact-us” And I do not follow redirects And I fill in “text” with “hello, guys” And I press “send” Then email with the subject “feedback” should have been sent And I should be redirected And I should see “message sent” inside “.notifications > p:first-child”

Slide 84

Slide 84 text

in order to give feedback as a site user i need to be able to use contact form Feature: contact form Scenario: Successfuly sending feedback through a contact form Given I am registered user And I am on homepage When I follow “contact-us” And I do not follow redirects And I fill in “text” with “hello, guys” And I press “send” Then email with the subject “feedback” should have been sent And I should be redirected And I should see “message sent” inside “.notifications > p:first-child”

Slide 85

Slide 85 text

in order to give feedback as a site user i need to be able to use contact form Feature: contact form Scenario: Successfuly sending feedback through a contact form Given I am registered user And I am on homepage When I follow “contact-us” And I do not follow redirects And I fill in “text” with “hello, guys” And I press “send” Then email with the subject “feedback” should have been sent And I should be redirected And I should see “message sent” inside “.notifications > p:first-child” Hey, techies it’s for you. Again!

Slide 86

Slide 86 text

in order to give feedback as a site user i need to be able to use contact form Feature: contact form Scenario: Successfuly sending feedback through a contact form Given I am registered user And I am on homepage When I follow “contact-us” And I do not follow redirects And I fill in “text” with “hello, guys” And I press “send” Then email with the subject “feedback” should have been sent And I should be redirected And I should see “message sent” inside notification area

Slide 87

Slide 87 text

in order to give feedback as a site user i need to be able to use contact form Feature: contact form Scenario: Successfuly sending feedback through a contact form Given I am registered user And I am on homepage When I follow “contact-us” And I do not follow redirects And I fill in “text” with “hello, guys” And I press “send” Then email with the subject “feedback” should have been sent And I should be redirected And I should see “message sent” inside notification area

Slide 88

Slide 88 text

in order to give feedback as a site user i need to be able to use contact form Feature: contact form Scenario: Successfuly sending feedback through a contact form Given I am registered user And I am on homepage When I follow “contact-us” And I fill in “text” with “hello, guys” And I send a feedback Then the feedback email should have been sent And I should see “message sent” inside notification area

Slide 89

Slide 89 text

in order to give feedback as a site user i need to be able to use contact form Feature: contact form Scenario: Successfuly sending feedback through a contact form Given I am registered user And I am on homepage When I follow “contact-us” And I fill in “text” with “hello, guys” And I send a feedback Then the feedback email should have been sent And I should see “message sent” inside notification area

Slide 90

Slide 90 text

case #3 Complex One

Slide 91

Slide 91 text

” I want students to optionally receive notifications about missed topics after failing tests. Your hypothetical client

Slide 92

Slide 92 text

1.Who?

Slide 93

Slide 93 text

1.Who? students

Slide 94

Slide 94 text

1.Who? students 2.Why?

Slide 95

Slide 95 text

1.Who? students 2.Why? to learn topics

Slide 96

Slide 96 text

in order to fully learn topics as a student i need to receive notifications about badly learned topics Feature: topics notifications

Slide 97

Slide 97 text

in order to fully learn topics as a student i need to receive notifications about badly learned topics Feature: topics notifications Scenario: Recieving notification about badly learned topics Given there is a test “test1” with questions: | topic | question | answers | correct | | math | 2+7 | 5, 8, 3, 9 | 9 | And I am authenticated student And I have activated notifications When I follow “test1” And I answer “5” for first question Then I should see “Test is not passed” And I should see “Learn math more”

Slide 98

Slide 98 text

in order to fully learn topics as a student i need to receive notifications about badly learned topics Feature: topics notifications Scenario: Recieving notification about badly learned topics Given there is a test “test1” with questions: | topic | question | answers | correct | | math | 2+7 | 5, 8, 3, 9 | 9 | And I am authenticated student And I have activated notifications When I follow “test1” And I answer “5” for first question Then I should see “Test is not passed” And I should see “Learn math more”

Slide 99

Slide 99 text

in order to fully learn topics as a student i need to receive notifications about badly learned topics Feature: topics notifications Scenario: Recieving notification about badly learned topics Given there are test “test1” with questions: | topic | question | answers | correct | | math | 2+7 | 5, 8, 3, 9 | 9 | And I am authenticated student And I have activated notifications When I follow “test1” And I answer “5” for first question Then I should see “Test is not passed” And I should see a “Learn math more” Later we’ve discovered, that this option should be available only for teacher accounts and should not be visible to students.

Slide 100

Slide 100 text

1.Who?

Slide 101

Slide 101 text

1.Who? teacher

Slide 102

Slide 102 text

1.Who? teacher 2.Why?

Slide 103

Slide 103 text

1.Who? teacher 2.Why? to help students

Slide 104

Slide 104 text

in order to ensure students learn topics well as a teacher i need to be able to activate failed topics notifications Feature: topics notifications Scenario: Student with activated notifications should receive them.

Slide 105

Slide 105 text

in order to ensure students learn topics well as a teacher i need to be able to activate failed topics notifications Feature: topics notifications Scenario: Student with activated notifications should receive them. Given there is a test “test1” with questions: | topic | question | answers | correct | | math | 2+7 | 5, 8, 3, 9 | 9 | And I am authenticated teacher And I have activated notifications for student “everzet” When student “everzet” fails test “test1” Then he should see “Learn math more”

Slide 106

Slide 106 text

case #4 Technical One

Slide 107

Slide 107 text

in order to ensure that all emails have been sent as an technical administrator i need to be able to send all delayed emails through CLI Feature: sending delayed emails Scenario: Successfully sending delayed emails through CLI Given I am at the project root And there are 3 delayed emails in the project When I run “app/console project:delayed-emails:send” Then it should return 0 And 3 emails should have been sent

Slide 108

Slide 108 text

in order to ensure that all emails have been sent as an technical administrator i need to be able to send all delayed emails through CLI Feature: sending delayed emails Scenario: Successfully sending delayed emails through CLI Given I am at the project root And there are 3 delayed emails in the project When I run “app/console project:delayed-emails:send” Then it should return 0 And 3 emails should have been sent ?

Slide 109

Slide 109 text

in order to ensure that all emails have been sent as a technical administrator i need to be able to send all delayed emails through CLI Feature: sending delayed emails Scenario: Successfully sending delayed emails through CLI Given I am at the project root And there are 3 delayed emails in the project When I run “app/console project:delayed-emails:send” Then it should return 0 And 3 emails should have been sent

Slide 110

Slide 110 text

” I think the real difference between mid-level and pro-level Behat users is the understanding of roles and their place in features. © Ryan Weaver

Slide 111

Slide 111 text

Questions?

Slide 112

Slide 112 text

” I think the real difference between mid-level and pro-level Behat users is the understanding of roles and their place in features. © Ryan Weaver Awesome @weaverryan and my good friend has a wedding right now with amazing @leannapelhalm. Tweet them congrats right now!

Slide 113

Slide 113 text

joind.in/6592