behavior-driven development (bdd) in context

36
Behavior-Driven Development in Context ALEXANDER KRESS TORONTO AGILE AND SOFTWARE 2014

Upload: alexkress

Post on 07-Jul-2015

373 views

Category:

Software


3 download

DESCRIPTION

Behavior Driven Development (BDD) is an essential part of an Agile implementation. What makes BDD so powerful is that it brings all members of a scrum team together in the common goal of defining and releasing a quality product. The talk will provide an introduction to BDD: Gherkin, writing BDD scenarios, common frameworks. The second part of the talk will focus on how BDD fits into the SCRUM team. We will concentrate on ways BDD can be used to bridge the communication gap often present between various SCRUM players to enable them to become more productive by using a common language.

TRANSCRIPT

Page 1: Behavior-Driven Development (BDD) in context

Behavior-Driven Development in ContextALEXANDER KRESS

TORONTO AGILE AND SOFTWARE 2014

Page 2: Behavior-Driven Development (BDD) in context

About meDevelopment manager at

Worked with BDD based process for 5 years

Blog devmngr.wordpress.com

Twitter @al3xkress

Page 3: Behavior-Driven Development (BDD) in context

The sales pitchBDD is a natural addition to an Agile process

BDD enhances communication in an agile group

BDD leads to fewer bugs and misunderstandings

BDD is easy to introduce and understand

Lots of open source tools exists to support a BDD roll out

Page 4: Behavior-Driven Development (BDD) in context

Mанифест“Аджаил”-манифест разработки программного обеспечения

Люди и взаимодействие важнее процессов и инструментовРаботающий продукт важнее исчерпывающей документацииСотрудничество с заказчиком важнее согласования условий контрактаГотовность к изменениям важнее следования первоначальному плану

То есть, не отрицая важности того, что справа, мы всё-таки больше ценим то, что слева.

Page 5: Behavior-Driven Development (BDD) in context

ManifestoManifesto for Agile Software Development

Individuals and interactions over processes and toolsWorking software over comprehensive documentationCustomer collaboration over contract negotiationResponding to change over following a plan

That is, while there is value in the items onthe right, we value the items on the left more.

Page 6: Behavior-Driven Development (BDD) in context

Common languagePO Dev QA

Page 7: Behavior-Driven Development (BDD) in context

BDD in Context

From User Stories to BDD

Page 8: Behavior-Driven Development (BDD) in context

The user story

As a Twitter user I would like to be able to post status updates In order to alert my followers to my latest doings

How would you break this up?

Page 9: Behavior-Driven Development (BDD) in context

Let’s add TDDAdd a test

Run all tests and see if the new one fails

Write some code

Run the automated tests and see them succeed

Refactor code

Repeat

Page 10: Behavior-Driven Development (BDD) in context

Writing tests is hardTo consider:

Which parts of the story do we want to test?

How do we structure test names to make them readable?

Would specific keywords in test names better define what they do?

What if we stopped thinking about tests and start thinking about behaviors?

Page 11: Behavior-Driven Development (BDD) in context

Behavior-Driven Development

BDD is a second-generation, outside–in, pull-based, multiple-stakeholder, multiple-scale, high-automation, agilemethodology. It describes a cycle of interactions with well-defined outputs, resulting in the delivery of working, tested software that matters.

Dan North

Also see http://dannorth.net/introducing-bdd/

Page 12: Behavior-Driven Development (BDD) in context

BDD in Context

Nuts and Bolts

Page 13: Behavior-Driven Development (BDD) in context

Gherkin – the languageFeature: Some terse yet descriptive text of what is desired In order to realize a named business value.

Scenario: Some determinable business situation

Given some precondition

And some other precondition

When some action by the actor

And some other action

And yet another action

Then some testable outcome is achieved

And something else we can check happens too

Behat documentation

Step

Body

Page 14: Behavior-Driven Development (BDD) in context

Gherkin – Elevating ExerciseFeature: As a condo resident I want to use any of the two available elevators to get from floor to floor

Scenario: Getting into an elevator from the ground floor

GivenAnd

WhenAndAnd

ThenAnd

Page 15: Behavior-Driven Development (BDD) in context

Gherkin – Elevating ExerciseFeature: As a condo resident I want to use any of the two available elevators to get from floor to floor

Scenario: Getting into an elevator from the ground floor

Given No Elevator is present on the ground floor

And An elevator has not been requested

And Elevator A is not moving, currently at floor 2

And Elevator B is going up, currently at floor 5

When I press the up button

Then Elevator A gets the call

And Elevator A arrives on the ground floor and opens doors

Page 16: Behavior-Driven Development (BDD) in context

Gherkin – Elevating ExerciseFeature: As a condo resident I want to use any of the two available elevators to get from floor to floor

Scenario: Getting into an elevator from the ground floor

Given [No] Elevators are present on the [ground] floor

And An elevator has not been requested

And Elevator [A] is not moving, currently at floor [2]

And Elevator [B] is going up, currently at floor [5]

When I press the [up] button

Then Elevator [A] gets the call

And Elevator [A] arrives on the [ground] floor and opens doors

Page 17: Behavior-Driven Development (BDD) in context

From Gherkin to CodeJava

Ruby

Python Lettuce --->

PHP

JavaScript

and many others API

Page 18: Behavior-Driven Development (BDD) in context

From Gherkin to Code

BDD Step: Elevator A gets the call

BDD Framework: ElevatorAPI.callElevator(ground level, direction up);

BDD Framework: If(Not ElevatorAPI.callAcknowledged(ground level))

Throw new Exception(“Elevator not called”);

BDD Step: I press the [up] button

Page 19: Behavior-Driven Development (BDD) in context

DemoFeature: User status update

Scenario: Normal flow, user is able to login and post a status update

Given I go to "www" with url "/"

And I fill in element "//*[@id='signin-email']" with value "agiledemo"

And I fill in element "//*[@id='signin-password']" with value

"demoagile"

And I click element "//*[@id='front-

container']/div[2]/div[2]/form/table/tbody/tr/td[2]/button"

And I verify current url path is "/"

And I verify text present "AgileDemo"

And I verify text present "@agiledemo"

And I ensure text not present "Writing a BDD presentation"

When I fill in element "//*[@id='tweet-box-mini-home-profile']"

with value "Writing a BDD presentation"

And I click element

"//*[@id='timeline']/div[1]/div/form/div[2]/div[2]/button"

Then I verify text present "Writing a BDD presentation"

Page 20: Behavior-Driven Development (BDD) in context

BDD in Context

Tying into Agile

Page 21: Behavior-Driven Development (BDD) in context

Common languagePO Dev QA

Page 22: Behavior-Driven Development (BDD) in context

Common languagePO Dev QA

BDD as acceptance

criteria

BDD as requirements definition and Test First Then

Code methodology

BDD as functionality

definition and automated regression

Page 23: Behavior-Driven Development (BDD) in context

Working together

Anyone can write a BDD!

Page 24: Behavior-Driven Development (BDD) in context

Working together

We define our own language!

Page 25: Behavior-Driven Development (BDD) in context

Working togetherOptimizing resource utilization

PO

DEV QAScenarios and steps

Page 26: Behavior-Driven Development (BDD) in context

Adding BDD to your process

Work with POs to understand and learn to love BDDs

Work with developers to read and write BDDs

QA will be your biggest fan

Page 27: Behavior-Driven Development (BDD) in context

Working with BDDMind the testing pyramid (Mike Cohn)

Write BDDs in the same sprint

Refactor, Refactor, Refactor

BDD -> CI -> Regression report

UI

Service

Unit

Page 28: Behavior-Driven Development (BDD) in context

Sample Regression Report

Page 29: Behavior-Driven Development (BDD) in context

FAQHow to create coverage for an existing system?

Which BDD framework language to pick?

Why not use QTP or some version of clicks recorder/capture?

Do POs really need to speak “fluent” Gherkin?

Page 30: Behavior-Driven Development (BDD) in context

Behavior-Driven DevelopmentBDD is a second-generation, outside–in, pull-based, multiple-stakeholder, multiple-scale, high-automation, agilemethodology. It describes a cycle of interactions with well-defined outputs, resulting in the delivery of working, tested software that matters.

Individuals and interactions over processes and toolsWorking software over comprehensive documentationCustomer collaboration over contract negotiationResponding to change over following a plan

Page 31: Behavior-Driven Development (BDD) in context

Questions

More slides this way

Page 32: Behavior-Driven Development (BDD) in context

RedFlagDeals Case StudyQ1 2012 – Large code base, no unit test, manual QA only

Q2 2012 – BDD framework introduced, QA start to dabble in it

Q3 2012 – First new component to have 100% BDD code coverage

Q1 2013 – BDD roll out across the team, PO training

Q2 2013 – Over 60% coverage on legacy components

Today – 587 scenarios, 10,353 steps (executed)Full nightly regressionCommit triggered BDD executionAgreed on failure review and correction processAutomation being part of the Definition of Done

Page 33: Behavior-Driven Development (BDD) in context

More Gherkin featuresTags

@DailyRegression

Feature: rss

@STORY-5859 @Staging @Local

Scenario: check vital signs

Given I go to …

TablesAnd call the url “www.site.com” with parameters

| Parameter Name | Parameter Value |

| search_string | agile |

| page_number | 5 |

Page 34: Behavior-Driven Development (BDD) in context

Refactoring stepsWhen I click on the Submit button

When I click on the Clear button

When I click on the “Publish” button

When I hover over the “Help” button

When I “hover over” the “Help” button

When I “hover over” the “Avatar” image

When I “hover over” the control “image” called “Avatar”

Page 35: Behavior-Driven Development (BDD) in context

Using MocksBDD driven automation behaves like a user, easy to start clicking on “real” or staging apps/sites/etc.

Somewhere, someone had just put up a prod database snapshot

Page 36: Behavior-Driven Development (BDD) in context

Closing pitchCommon language!

Code based documentation that is readable by all.

Better resource utilization in the team.

A natural extension to an Agile process.