Slide 1

Slide 1 text

A short introduction to BDD (BDD from the eyes of a test-first maniac) by Jakub Zalas Polish Developers Meetup in London

Slide 2

Slide 2 text

@jakzal @jakub_zalas @SensioLabsUK £

Slide 3

Slide 3 text

Act 1: Going inside out or how it all started

Slide 4

Slide 4 text

Test Driven Development

Slide 5

Slide 5 text

Test Driven Development Introducing BDD, Dan North http://dannorth.net/introducing-bdd/

Slide 6

Slide 6 text

Test Driven Development Behaviour Introducing BDD, Dan North http://dannorth.net/introducing-bdd/

Slide 7

Slide 7 text

public class DeliveryRepositoryTest extends TestCase { public void testFindDelivery() { // ... } public void testFindDelivery2() { // ... } }

Slide 8

Slide 8 text

public class DeliveryRepositoryTest extends TestCase { public void testFindsDeliveryByTrackingCode() { // ... } public void testFailsForInvalidTrackingCode() { // ... } } DeliveryRepository •  finds delivery by tracking code •  fails for invalidtracking code

Slide 9

Slide 9 text

public class DeliveryControllerTest extends WebTestCase { public void testItShowsDeliveryDetailsForAValidTrackingCode() { // ... } public void testItDoesNotShowADeliveryForExpiredTrackingCode() { // ... } public void testItDoesNotShowADeliveryDeliveredMoreThanAMonthAgo() { // ... } } DeliveryController •  it shows delivery details for a valid tracking code •  it does not show a delivery for expired tracking code •  it does not show a delivery delivered more than a month ago

Slide 10

Slide 10 text

Act 2: Improving communication or how I thought I got it right

Slide 11

Slide 11 text

Customers should be able to sign in! Avatars generated on http://www.customsouthparks.com/

Slide 12

Slide 12 text

1. Open a browser 2. Put the site URL in the browser and press enter 3. Give username 4. Give password 5. Press submit button 6. Check if I gained access to the secured area

Slide 13

Slide 13 text

package poldev.controller; public class AuthController { public void signIn() { // ... } }

Slide 14

Slide 14 text

Signing in

Slide 15

Slide 15 text

As a Customer I want to sign in In order to be signed in

Slide 16

Slide 16 text

As a Customer I want to sign in In order to be signed in track my deliveries

Slide 17

Slide 17 text

As an Customer Owner I want to sign in In order to be signed in track my deliveries

Slide 18

Slide 18 text

As an Customer Owner I want to sign in Customers to sign in In order to be signed in track my their deliveries

Slide 19

Slide 19 text

When an anonymous user goes to the deliveries page Then he should see the signin form And he shouldn't see any delivery details

Slide 20

Slide 20 text

When a Customer goes to the deliveries page And gives his login details Then he should see a list of his deliveries

Slide 21

Slide 21 text

Feature: Tracking deliveries As a Customer I need to see a status of my delivery So I could know when it's going to be delivered

Slide 22

Slide 22 text

Feature: Tracking deliveries As a Customer I need to see a status of my delivery So I could know when it's going to be delivered

Slide 23

Slide 23 text

Feature: Tracking deliveries As a Customer I need to see a status of my delivery So I could know when it's going to be delivered Scenario: Clicking a tracking URL Scenario: Clicking a tracking URL month after delivery

Slide 24

Slide 24 text

Feature: Tracking deliveries As a Customer I need to see a status of my delivery So I could know when it's going to be delivered Scenario: Clicking a tracking URL Given I am waiting for a delivery And I received a confirmation message When I click the tracking URL from the message Then I should see a status of my delivery Scenario: Clicking a tracking URL month after delivery Given I my package was delivered a month ago And I kept the confirmation message When I click the tracking URL from the message Then I should be informed the tracking URL has expired

Slide 25

Slide 25 text

Feature: Tracking deliveries As a Customer I need to see a status of my delivery So I could know when it's going to be delivered Scenario: Clicking a tracking URL Given I am waiting for a delivery And I received a confirmation message When I click the tracking URL from the message Then I should see a status of my delivery Scenario: Clicking a tracking URL month after delivery Given I my package was delivered a month ago And I kept the confirmation message When I click the tracking URL from the message Then I should be informed the tracking URL has expired

Slide 26

Slide 26 text

Failing step Failing test Code Refactor Passing step External quality Internal quality

Slide 27

Slide 27 text

Act 3: Going outside in or focusing on a goal

Slide 28

Slide 28 text

"I need Customers to sign into the site to track their delivery." Mr Client

Slide 29

Slide 29 text

As a Customer I need to sign into the site So I could track my delivery

Slide 30

Slide 30 text

As a Customer I need to see my deliveries So I could know when it's going to be delivered

Slide 31

Slide 31 text

WHAT'S THE GOAL?

Slide 32

Slide 32 text

THE CLIENT CAME WITH A SOLUTION

Slide 33

Slide 33 text

"I need users to sign into the site to track their delivery." "Why?" "So they could see where's their package." "Why?" "What do you mean? They need to track their deliveries." "Yes, but why?"

Slide 34

Slide 34 text

"Well, our mission is to offer the most customer friendly courier services. We want to increase the number of satisfied customers." "Aha!" "So they wouldn't get impatient and file complaints when the delivery is delayed." "Why?" "So they could know when is it going to be delivered." "Why?"

Slide 35

Slide 35 text

< 5% of customers filing complaints Customers Support Notifications Contact the Customer if delivery is delayed Add expected delivery time to the confirmation message SMS notifications Add a tracking URL to the confirmation message E-mail notifications List of deliveries after signing in Prevent complaints Check delivery status Why? Who? How? What?

Slide 36

Slide 36 text

MAKE IMPACTS NOT SOFTWARE Gojko Adžić impactmapping.org

Slide 37

Slide 37 text

Thank you!

Slide 38

Slide 38 text

Credits •  https://www.flickr.com/photos/hinkelstone/5166544084 •  http://www.customsouthparks.com/ •  http://impactmapping.org •  http://dannorth.net/introducing-bdd/