behavior driven development

39
Test Faster with Behavior Driven Development Jennifer Starkey & Stephanie Vineyard

Upload: stephanie-vineyard

Post on 11-Jan-2017

45 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Behavior Driven Development

Test Fasterwith Behavior Driven Development

Jennifer Starkey & Stephanie Vineyard

Page 2: Behavior Driven Development

Why are we here?

Page 3: Behavior Driven Development

Business Analysis Service Lead, Agile trainer and coach

Board member of the IIBA DC Chapter

CSM, CSPO, PMP, ITIL

Stephanie Vineyard

Page 4: Behavior Driven Development

Business Analysis Lead on USCIS Verifications Project

CSM, CSPO, PMP

Jenn Starkey

Page 5: Behavior Driven Development

Why does testing matter?What is Behavior Driven Development?What is the impact?How do I use this?

Intentions

Page 6: Behavior Driven Development

Why does testing matter?

Page 7: Behavior Driven Development

BABOK: Verify and Validate

Requirements

Page 8: Behavior Driven Development

BABOK: Achieve stakeholders’

desired state

Page 9: Behavior Driven Development

Agile Manifesto

15

Individuals and interactions over Process and tools

Working software over Comprehensive documentation

Customer collaboration over Contract negotiation

Responding to change over Following a plan

We are uncovering better ways of developing software by doing it and helping others do it. Through this work we have come to value:

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

http://agilemanifesto.org/

Page 10: Behavior Driven Development

Value to USCISU.S. Citizen Immigration Service – Status

Verification System

Page 11: Behavior Driven Development

Enables better communication across cross-functional scrum teams

PO BA Dev Team

Page 12: Behavior Driven Development

Ensures the team delivers business

value.

Page 13: Behavior Driven Development

Helps to automateUAT!

Page 14: Behavior Driven Development

What is BDD?Behavior Driven Development

Page 15: Behavior Driven Development

Gherkin

gher·kinˈgərkin/noun1. a small variety of cucumber, or a young green cucumber used for pickling.Business readable, domain specific language

Page 16: Behavior Driven Development

Gherkin syntax

• Given < situation >• When < action >• Then < expected result >

16

Page 17: Behavior Driven Development

Let’s see it in action

Page 18: Behavior Driven Development

How USCIS Verifications is Using BDD

Code Gets Merged to MasterPipeline Runs all Cucumber Tests

Devs Write Code and Gherkin ScriptsFeeds the AC into Automated Testing Tool

BAs Assist the PO to Write ACGiven/When/Then

Page 19: Behavior Driven Development

BAs Enter Stories into Jira

Given unavailable user is logged in and viewing casesWhen the user selects available status Then the user sees their current status as availableAnd the verifier receives an active case

Page 20: Behavior Driven Development

Devs Write Gherkin Scripts

Page 21: Behavior Driven Development

Devs Merge Code

Page 22: Behavior Driven Development

UAT is Automated!

Page 23: Behavior Driven Development

What were the results?• Demo and implement agile best

practices in the federal government• Went from project kick-off to

production in 3 months• Continuously improve as a team

Page 24: Behavior Driven Development

Why does testing matter?What is Behavior Driven Development?What is the impact?How do I use this?

Intentions

Page 25: Behavior Driven Development

Try it out

Page 26: Behavior Driven Development

Example – start with the user story then create your BDD

User Story: As a customer, I want to review shipping costs in my shopping cart before checking out, so I can see if I will receive free shipping.

Acceptance Criteria:• Orders less than $50 pay shipping of $3.99• Orders greater than $50 have free shipping

Page 27: Behavior Driven Development

Gherkin syntax

• Given < situation >• When < action >• Then < expected result >

27

Page 28: Behavior Driven Development

Exercise 1Scenario: Standard Shipping RateGiven I am a customerAnd my order amount is $49.99When I view my cartThen I see that shipping costs are $3.99

Scenario: Free Shipping RateGiven I am a customerAnd my order amount is $50.00When I view my cartThen I see that shipping costs are $0.00

Page 29: Behavior Driven Development

Scenario OutlinesFeature: Determine shipping rate

Scenario Outline: Standard shipping rate• Given that I am a customer• And my order amount is <order amount>• When I view my cart• Then I see that shipping costs are <shipping cost>

Example Tables:| order amount | shipping cost| $49.99 | $3.99| $50.00 | $0.00| $75.00 | $0.00

Page 30: Behavior Driven Development

Exercises

• In small groups, review scenario 1 and 2.

• How could these be better written?

Page 31: Behavior Driven Development

Scenario 1

OkayExample:GivenanactiveuserwithvalidcredentialsandthatuserhaspreviouslysubmittedaticketWhenthatuserfindsapreviouslysubmittedticketinanactivestatusThenthatuserhastheoptionofsendingamessage

BetterExample:GivenIamanactiveuserwithvalidcredentialsAndIpreviouslysubmittedaticketAndtheticketisinanactivestatusWhenIfindapreviouslysubmittedticketThenIshouldseeanoptionforsendingamessage

Page 32: Behavior Driven Development

Exercise 2

OkayExample:GivenIamanunregistereduserWhenIenter“jsmith”in“username”and“secret123!”in“password”AndIpressthe“OK”buttonThenIsee“Profilesuccessfullycreated”ontheWelcomepage

BetterExample:GivenIamanunregistereduserAndIenter“<username>”AndIenter“<password>”WhenIpressthe“OK”buttonThenIsee“<message>”ontheWelcomepageExamples:

username password messagejsmith secret123! Profile successfully created

jsmith2 secret123 Your password must contain a special character

Feature: CreatenewaccountScenario: Usercreatesaccountsuccessfully

Page 33: Behavior Driven Development

Imperative Style

Feature: CreatenewaccountScenario: Usercreatesaccountsuccessfully

Imperative(Narrative)GivenIamanunregistereduserAndIamontheloginpageAndIenter<username>AndIenter<password>WhenIselectthe“OK”buttonThenIsee<message>onthewelcomepage

ImplementationDetail– whatifdecidetouseToken-basedauthenticationorsinglesign-on?

UIDetail– whatiftheuserinterfacechangesandyouselectnamefromadrop-downlistorselectaradiobutton?

Page 34: Behavior Driven Development

Declarative Style

Feature: CreatenewaccountScenario: Usercreatesaccountsuccessfully

Declarative(Informative)

GivenIamanunregistereduserAndIamontheloginpageWhenIsubmitvalidcredentialsThenIseethewelcomepage

Page 35: Behavior Driven Development

Side-by-side ComparisonFeature: CreatenewaccountScenario: Usercreatesaccountsuccessfully

Imperative(Narrative) Declarative(Informative)

GivenIamanunregistereduserAndIamontheloginpageAndIenter<username>AndIenter<password>WhenIselectthe“OK”buttonThenIshouldseethewelcomepage

GivenIamanunregistereduserAndIamontheloginpage

WhenIsubmitvalidcredentialsThenIshouldseethewelcomepage

Page 36: Behavior Driven Development

Background Statement

Page 37: Behavior Driven Development

Why does testing matter?What is Behavior Driven Development?What is the impact?How do I use this?

Were our intentions met?

Page 38: Behavior Driven Development

Jennifer StarkeyJennifer.starkey@excella.

com

LinkedIn: https://www.linkedin.com/in/jennifer-starkey

Stephanie Vineyard

Stephanie.vineyard@ex

cella.com

Twitter: @tesiemae

LinkedIn:

https://www.linkedin.co

m/in/smvineyard

Page 39: Behavior Driven Development

Behavior Driven Developmentis a product which has just enough features to gather validated learning about the product and its continued development...

Minimal Viable Product (MVP)is a product which has just enough features to gather validated learning about the product and its continued development.

Acceptance Testis a …

Agile ManifestoIndividuals and interactions over Process and toolsWorking product over Comprehensive documentationCustomer collaboration over Contract negotiationResponding to change over Following a plan

Terminology