outside in - behaviour driven development (bdd)

43
Copyright © 2013, AgileFAQs. All Rights Reserved. Behavior Driven Development Naresh Jain [email protected] @nashjain http://nareshjain.com

Upload: naresh-jain

Post on 06-May-2015

4.255 views

Category:

Technology


2 download

DESCRIPTION

The BDD Workshop offers a comprehensive, hands-on introduction to behavior driven development via an interactive-demo. Over the past decade, eXtreme Programming practices like Test-Driven Development (TDD) and Behaviour Driven Development (BDD) have fundamentally changed software development processes and inherently how engineers work. Practitioners claim that it has helped them significantly improve their collaboration with business, development speed, design & code quality and responsiveness to changing requirements. Software professionals across the board, from Internet startups to medical device companies to space research organizations, today have embraced these practices. This workshop explores the foundations of TDD & BDD with the help of various patterns, strategies, tools and techniques.

TRANSCRIPT

Page 1: Outside In - Behaviour Driven Development (BDD)

Copyright © 2013, AgileFAQs. All Rights Reserved.

Behavior Driven Development

Naresh [email protected]

@nashjain http://nareshjain.com

Page 2: Outside In - Behaviour Driven Development (BDD)

Copyright © 2013, AgileFAQs. All Rights Reserved.

Pick one scenario and in relation to your scenario, what are the specific observable results that will tell you that the activity has been successfully completed?

Going out for Movie (THX sound and Digital projection)

Going out for meal (one veg.)

Going shopping ($50)[5 Minutes]

Present back to the group your findings. [3 minutes per group]

Warmup Scenarios

Page 3: Outside In - Behaviour Driven Development (BDD)

Commercial Break!

Page 4: Outside In - Behaviour Driven Development (BDD)

Copyright © 2013, AgileFAQs. All Rights Reserved.

Page 5: Outside In - Behaviour Driven Development (BDD)

Tech Talks!

Page 6: Outside In - Behaviour Driven Development (BDD)
Page 7: Outside In - Behaviour Driven Development (BDD)

Elevator Pitch

Business Goals

Chartering

PragmaticPersonas

User Goals

Day in Life of each Persona

Scenarios &

Narratives

Personas

Activity Map

Task MapInteraction DesignUI Sketch

Story Mapping

PrioritizationGrouping by ThemesReiterating

Planning

User Stories

AcceptanceCriteria

User Story Authoring

Product  Discovery  -­‐  Overview

Page 8: Outside In - Behaviour Driven Development (BDD)

Vision

Goal

Capability

Feature

Story

Scenario

Code

Elevator Pitch

Business Goals

Chartering

PragmaticPersonas

User Goals

Day in Life of each Persona

Scenarios & Narratives

Personas

Activity Map

Task MapInteraction DesignUI Sketch

Story Mapping

PrioritizationGrouping by ThemesReiterating

Planning

User StoriesAcceptanceCriteria

User Story Authoring

Page 9: Outside In - Behaviour Driven Development (BDD)

Copyright © 2013, AgileFAQs. All Rights Reserved.

What are we really trying to build?

User Stories

Page 10: Outside In - Behaviour Driven Development (BDD)

Copyright © 2013, AgileFAQs. All Rights Reserved.

Story is a smallest piece of functionality that add business value

Stories should follow Ron Jeffries’ 3 Cs

Card – Placeholder for conversation

Conversation – Actual discussion between dev team and user

Confirmation – Acceptance criteria to determine when the story is finished

What is a Story?

Page 11: Outside In - Behaviour Driven Development (BDD)

Copyright © 2013, AgileFAQs. All Rights Reserved.

In order to... <user goal/business justification>

As a .. <user who requires this feature>

I need .. <do something>

Typical Story Format

Story Title - Actor Action Context

Page 12: Outside In - Behaviour Driven Development (BDD)

Copyright © 2013, AgileFAQs. All Rights Reserved.

Title: Keen Reader subscribes to a blog

In order to stay up-to-date with new posts

As a keen reader of your blog

I need to subscribe to your blog

Story Example

Page 13: Outside In - Behaviour Driven Development (BDD)

Copyright © 2013, AgileFAQs. All Rights Reserved.

Title: Social Networking Enthusiast uploads profile picture

In order for my friends to see how I look and recognize me

As a Social Networking Enthusiast

I need to upload my profile picture

Another Story Example

Page 14: Outside In - Behaviour Driven Development (BDD)

Copyright © 2013, AgileFAQs. All Rights Reserved.

As a ____, I want to be able to ____ so

that ____

Product Backlog

Might have an initial estimate (perhaps for both analysis and development),

and an expression of technical and business

confidence that this is real and achievable

As a ____, I want to be able to ____ so

that ____

I will know this is done when _______

Release Backlog

More detailed estimate, and a specific acceptance test – low confidence stories might

be “spiked” or prototyped

As a ____, I want to be able to ____ so

that ____

I will know this is done when _______

To do this I must:1) _____2) _____

Sprint Backlog

Possible automation of the acceptance

test

Development team breaks out the detail of work

needed to pass test

Release planning Iteration planning

Business Goals

Inception

Stories are fundamental unit of activity

User Goals

Page 15: Outside In - Behaviour Driven Development (BDD)

Copyright © 2013, AgileFAQs. All Rights Reserved.

Stories should follow the INVEST principle:

Independent

Negotiable

Valuable

Estimateable

Small

Testable

What makes a good Story?

Page 16: Outside In - Behaviour Driven Development (BDD)

Copyright © 2013, AgileFAQs. All Rights Reserved.

ScenariosAcceptance Criteria

Page 17: Outside In - Behaviour Driven Development (BDD)

Copyright © 2013, AgileFAQs. All Rights Reserved.

Is a set of conditions that the Story must meet for it to be accepted as complete

Is typically provided by the customer or product owner.

Is not a replacement for conversation.

Is the results of the conversation

Scenarios are NOT tests

Scenario

Page 18: Outside In - Behaviour Driven Development (BDD)

Copyright © 2013, AgileFAQs. All Rights Reserved.

Scenario should contain:

ACTOR

VERB – DESCRIBING A BEHAVIOR

OBSERVABLE RESULT

To accommodate pre-conditions scenarios can be expressed as

Given [Precondition]

When [Actor + Action]

Then [Observable Result]

Writing Scenarios

Page 19: Outside In - Behaviour Driven Development (BDD)

Copyright © 2013, AgileFAQs. All Rights Reserved.

Example

Given the user has a valid facebook account and a digital picture on her computer,

When she uploads a picture in facebook,

Then her the picture should be visible to all her friends in her network.

Given an user is trying to find a friend on facebook,

When the user searches for a person using their name,

Then their profile picture should be displayed along with other details.

In order to keep facebook's reputation intact and stay out of legal hassles

As owner of facebook,

I need users to upload authentic, personal profile picture

Social Networking Enthusiast uploads profile picture

Page 20: Outside In - Behaviour Driven Development (BDD)

Copyright © 2013, AgileFAQs. All Rights Reserved.

Cucumber Style BDDFeature: Login In order to access secure content As a registered user I need to authenticate myself Scenario: Login with valid credentials Given I am not logged in When I try to login with "test" and "secret" Then I should be logged in Scenario: Login with invalid credentials Given I am not logged in When I try to login with "test" and "wrongpassword" Then I should not be logged in And I should be shown error message "Invalid username or password"

Page 21: Outside In - Behaviour Driven Development (BDD)

Copyright © 2013, AgileFAQs. All Rights Reserved.

Step Definition

Given /^I am not logged in$/ do browser.navigate_to("http://your_url.com")end

When /^I try to login with "([^\"]*)" and "([^\"]*)"$/ do |username, password| browser.textbox("user").value = username browser.password("password").value = password browser.submit("Login").clickend

Then /^I should be logged in$/ do if !browser.button("Logout").exists? raise "Not logged in" endend

Then /^I should be shown error message "([^\"]*)"$/ do |msg| value = browser.div("errorMessage").text if value != msg raise "Incorrect message: #{value}" endend

Then /^I should not be logged in$/ do if !browser.submit("Login").exists? raise "Logged in" endend

Page 22: Outside In - Behaviour Driven Development (BDD)

Copyright © 2013, AgileFAQs. All Rights Reserved.

Acceptance TestsAcceptance Criteria & Tests: Definition

Acceptance Criteria

Examples (data + scenarios)

Acceptance Tests

+

Page 23: Outside In - Behaviour Driven Development (BDD)

Copyright © 2013, AgileFAQs. All Rights Reserved.

Scenarios =

Executable Tests

Page 24: Outside In - Behaviour Driven Development (BDD)

Copyright © 2013, AgileFAQs. All Rights Reserved.

Tasks

To accomplish this story:

we start off with a simple upload and image display

restrict user to only upload certain image types (gif, jpg and png)

figure out where to store the image. (performant and fault-tolerant)

scale down (size, resolution, etc.) of the image

and so on...

Team members further break down each story into tasks that needto be completed to meet the acceptance criteria for the story.

Page 25: Outside In - Behaviour Driven Development (BDD)

Copyright © 2013, AgileFAQs. All Rights Reserved.

Demo

Page 26: Outside In - Behaviour Driven Development (BDD)

Copyright © 2013, AgileFAQs. All Rights Reserved.

BDD

Page 27: Outside In - Behaviour Driven Development (BDD)

Copyright © 2013, AgileFAQs. All Rights Reserved.

Key Questions

Are we building the right product?

Are we building the product right?

Business Facing

Technology/Implementation Facing

Page 28: Outside In - Behaviour Driven Development (BDD)

Copyright © 2013, AgileFAQs. All Rights Reserved.

Brian Marick’s Test Categorization

Business Facing

Technology/Implementation Facing

Supp

orts

Pro

gram

min

gC

ritique product

Page 29: Outside In - Behaviour Driven Development (BDD)

Copyright © 2013, AgileFAQs. All Rights Reserved.

It Helps to Think of Tests this way...

Business Facing

Technology/Implementation Facing

Dri

ves

Dev

elop

men

t Critique productUnit Testing

Acceptance Testing Low-fi prototypes

Exploratory TestingUI and Usability Testing

Performance TestingSystem Tests

Page 30: Outside In - Behaviour Driven Development (BDD)

Copyright © 2013, AgileFAQs. All Rights Reserved.

Inverting the Testing Pyramid

Unit Tests

IntegrationTests

End-to-EndGUI Tests 80-90%

5-15%

1-5%

Typical testing strategies lead to an inverted testing pyramid...

Manual Checking

Page 31: Outside In - Behaviour Driven Development (BDD)

Copyright © 2013, AgileFAQs. All Rights Reserved.

Inverting the Testing Pyramid

Unit Tests

Biz Logic Acceptance Tests

Integration Test

Workflow Tests

End to End Flow Tests

GUITests

1%

70%

10%

9%

6%

4%

PerformanceTests

SecurityTests

This is the need of the hours...

One Layer Below GUI

Page 32: Outside In - Behaviour Driven Development (BDD)

Copyright © 2013, AgileFAQs. All Rights Reserved.

TDD Rhythm - Test, Code, Refactor

Add a Test

Run the Test

Make a little change

Run the Test

Refactor

Fail

Pass

Fail

Pass

Test Driven Development

Page 33: Outside In - Behaviour Driven Development (BDD)

Copyright © 2013, AgileFAQs. All Rights Reserved.

Behavior Driven Development

Iteration

Automated Acceptance Tests

AutomatedAcceptance Tests

Story

Scenario

Scenario

ExploratoryTesting

Automated UI Tests

TESTS

PERFORMENCE

Automated Unit Test

Page 34: Outside In - Behaviour Driven Development (BDD)

Copyright © 2013, AgileFAQs. All Rights Reserved.

Benefits of BDD

Page 35: Outside In - Behaviour Driven Development (BDD)

Copyright © 2013, AgileFAQs. All Rights Reserved.

Why?

Page 36: Outside In - Behaviour Driven Development (BDD)

Copyright © 2013, AgileFAQs. All Rights Reserved.

Better Commitment and Buy-inFocus on Business Value

Page 37: Outside In - Behaviour Driven Development (BDD)

Copyright © 2013, AgileFAQs. All Rights Reserved.

Ubiquitous Domain Language

Page 38: Outside In - Behaviour Driven Development (BDD)

Copyright © 2013, AgileFAQs. All Rights Reserved.

Right focus

Page 39: Outside In - Behaviour Driven Development (BDD)

Copyright © 2013, AgileFAQs. All Rights Reserved.

Evolutionary Design

Page 40: Outside In - Behaviour Driven Development (BDD)

Copyright © 2013, AgileFAQs. All Rights Reserved.

Breaking the Knowledge Silos in Distributed Team

Page 41: Outside In - Behaviour Driven Development (BDD)

Copyright © 2013, AgileFAQs. All Rights Reserved.

Greater ROI

Page 42: Outside In - Behaviour Driven Development (BDD)

Copyright © 2013, AgileFAQs. All Rights Reserved.

Predictability & Confidence

Page 43: Outside In - Behaviour Driven Development (BDD)

Copyright © 2013, AgileFAQs. All Rights Reserved.

Thank you

Naresh [email protected]