SlideShare a Scribd company logo
1 of 20
www.unicomlearning.com

India Agile Week-2013
26-Oct-2013 at Pune

BDD in an Agile world
Gaurav Awasthi
Senior Architect and Technology Evangelist

www.agileinbusiness.com
Concept, Practice, Tools

www.unicomlearning.com

Concept, Practice and finally Tools
Concepts are beyond Practices and Tools
Good Tools are better suited to Practices which
help internalize Concepts quickly

UNICOM Presents

India Agile Week-2013
The BDD World…
 Concepts
 Write software that matters
 In close collaboration with Stakeholder

 Practices
 Writing features, scenarios
 Write executable specs

 Tools
 Cucumber
 JBehave
 RSpecs
UNICOM Presents

India Agile Week-2013

www.unicomlearning.com
BDD…by definition

www.unicomlearning.com

BDD is a second-generation,
outside-in,
multiple-stakeholder,
high-automation,
agile methodology.
It describes a cycle of interactions with well-defined
outputs, resulting in the delivery of working, tested software
that matters.
Dan North
UNICOM Presents

India Agile Week-2013
Buzzword Agnostic Benefits…

www.unicomlearning.com

• Seamless mapping between Requirement statements and
executable tests

• Specification by example
• Loose grammar of the domain
• Brings Testers/QA to the forefront of development
process
• Self verifying documentation

• Evolves behavior as the domain understanding changes
UNICOM Presents

India Agile Week-2013
Co-existence with TDD
Write a failing
feature test

BDD

www.unicomlearning.com

Write a
failing unit
test
TDD

Refactor
TDD – Develop it the
right way
BDD – Develop the right
thing
UNICOM Presents

India Agile Week-2013

Make the
test pass
And what about DDD ?
• Domain Driven Design
• Ubiquitous Language
• gives vocabulary
• Inside Out

• Behavior Driven Development
• Sentences out of the vocabulary
• Description of the behavior
• Outside In

UNICOM Presents

India Agile Week-2013

www.unicomlearning.com
The BDD Practice

www.unicomlearning.com

1. Describe the behavior in plain text – Features and Scenarios
2. Write a step definition for each Step
3. Run it and watch it fail
4. Write code to make the step pass
5. Run it again and see the step pass
6. Repeat step 2 – 5 until green like a Cuke
7. Repeat step 1 – 6 until the money runs out

UNICOM Presents

India Agile Week-2013
The Tool - Cucumber
Why Cucumber ?
• one of the least technical tools
• a very active open source project
• supports a variety of languages

UNICOM Presents

India Agile Week-2013

www.unicomlearning.com
Slicing Cucumber

www.unicomlearning.com

•

JBehave -> ported to Ruby -> RBehave -> rewritten from scratch > RSpec -> + story runner -> Cucumber -> Cucumber-JVM

•

Aslak Hellesoy ported Cucumber to Java (cucumber-jvm)

•

Cucumber comes with Ruby (the original), Java, .NET, Adobe Flex,
Python, Perl, Erlang, PHP

•

Full stack for acceptance tests include – Browser Driver and
Browser

UNICOM Presents

India Agile Week-2013
Gherkin

www.unicomlearning.com

• A Business Readable, Domain Specific Language that
Cucumber understands
• Line-based language that Cucumber uses to define
behaviors in the form of features, scenarios, and steps

• Serves 3 purposes :
•
•
•

Automated Tests
Documentation
Specs for Code to be written

• Source files have .feature extension. Single Gherkin source
file contains a description of a single feature
UNICOM Presents

India Agile Week-2013
Gherkin syntax
Feature : title

www.unicomlearning.com

 As a [ person or role who will benefit ]
 I want [ some feature ]
 So that [ benefit or value of the feature ]
UNICOM Presents

India Agile Week-2013
Gherkin syntax
Scenario : title
 Given [ some initial context ]
 When [ an event occurs]
 Then [ ensures some outcome ]
UNICOM Presents

India Agile Week-2013

www.unicomlearning.com
Example
Feature: Customer
purchases a device
• As a Customer
• I want to purchase a Bluetooth
device
• So that I can make or receive a
hands free call

www.unicomlearning.com

Scenario : Customer has a
credit note valued more
than the receipt amount
• Given the customer is on the till

• And he has a credit note of Rs
1000
• And the receipt amount is Rs 500
• When the balance amount is
paid
• Then the billing completes

UNICOM Presents

India Agile Week-2013
Cucumber Options
@RunWith(Cucumber.class)
@Cucumber.Options (
tags = “@focus”,
features= “classpath:billing.feature”
)
public class CukeRunner {
}
Some common options :
• features – path to the feature files
• glue – where to look for step definition and hooks
• tags – what tags in the features should be executed
• format – what formatters to use
• …
UNICOM Presents

India Agile Week-2013

www.unicomlearning.com
CLI Option

www.unicomlearning.com

• Several Runners
•
•
•

Command Line Interface
JUnit Runner
Android Runner

cucumber-core
cucumber-junit
cucumber-android

• java cucumber.cli.Main [options] [FILE|DIR]
•

--glue , --format, --tags, --name …

• Benefit :
•
•

Independent of JUnit
Integration with Ant

UNICOM Presents

India Agile Week-2013
Demo Code
•

Create a maven project, with cucumber-jvm related
dependencies
•

•

Feature: Withdrawing money from a User account
•
Scenario: Withdrawing money from a User's account should
reduce money in the current balance
•
Given a User has $100 in his account
•
When $50 is withdrawn from the account
•
Then the balance should be $50

Write Java wrapper class – like CukeRunner,
•

•
•
•

cucumber-core, cucumber-java, cucumber-junit

Write a Feature and a scenario with steps
•

•

www.unicomlearning.com

annotated with RunWith and Cucumber.Options

Run the class, let it fail
Implement Steps, Run again
See it green like a cuke

UNICOM Presents

India Agile Week-2013
And the debate

www.unicomlearning.com

To TDD, To BDD
or
To prefer one over the other

UNICOM Presents

India Agile Week-2013
References
•
•
•
•
•

www.unicomlearning.com

That's not BDD, that's just Cucumber by Chris Parsons
Introducing BDD by Dan North
http://dannorth.net/whats-in-a-story/ by Dan North
http://cukes.info/install-cucumber-jvm.html
http://cukes.info/api/cucumber/jvm/javadoc/cucumber/api/junit/C
ucumber.Options.html

UNICOM Presents

India Agile Week-2013
www.unicomlearning.com

Speaker name: Gaurav Awasthi
Email ID: gawasthi22@gmail.com

India Agile Week-2013
Organized by
UNICOM Trainings & Seminars Pvt. Ltd.
contact@unicomlearning.com

More Related Content

Similar to Behaviour Driven Development - Cuking the Agile world

How to Integrate UX and Agile
How to Integrate UX and AgileHow to Integrate UX and Agile
How to Integrate UX and AgileUserZoom
 
Evolution and History of Angular as Web Development Platform.pdf
Evolution and History of Angular as Web Development Platform.pdfEvolution and History of Angular as Web Development Platform.pdf
Evolution and History of Angular as Web Development Platform.pdfiFour Technolab Pvt. Ltd.
 
Accessibility Testing - Using Asqatasun - Meetup Webinar
Accessibility Testing - Using Asqatasun - Meetup WebinarAccessibility Testing - Using Asqatasun - Meetup Webinar
Accessibility Testing - Using Asqatasun - Meetup WebinarKeyur Shah
 
Angular Meetup 1 - Angular Basics and Workshop
Angular Meetup 1 - Angular Basics and WorkshopAngular Meetup 1 - Angular Basics and Workshop
Angular Meetup 1 - Angular Basics and WorkshopNitin Bhojwani
 
India agile week chennai - Agile maturity to scale for enterprise & blendin...
India agile week   chennai - Agile maturity to scale for enterprise & blendin...India agile week   chennai - Agile maturity to scale for enterprise & blendin...
India agile week chennai - Agile maturity to scale for enterprise & blendin...Venkat Janardhanam, MS, MBA
 
5 Best Automation Testing Tools to Speed up Testing.pdf
5 Best Automation Testing Tools to Speed up Testing.pdf5 Best Automation Testing Tools to Speed up Testing.pdf
5 Best Automation Testing Tools to Speed up Testing.pdfSerena Gray
 
Canada DevOps Summit 2020 Presentation Nov_03_2020
Canada DevOps Summit 2020 Presentation Nov_03_2020Canada DevOps Summit 2020 Presentation Nov_03_2020
Canada DevOps Summit 2020 Presentation Nov_03_2020Varun Manik
 
Unicom DevCon - CI/CD for Asp.net core apps using Docker
Unicom DevCon - CI/CD for Asp.net core apps using DockerUnicom DevCon - CI/CD for Asp.net core apps using Docker
Unicom DevCon - CI/CD for Asp.net core apps using DockerSwaminathan Vetri
 
Continuous delivery @ iyzico
Continuous delivery @ iyzicoContinuous delivery @ iyzico
Continuous delivery @ iyzicoÜmit Ünal
 
Browserscope oscon 2011
Browserscope oscon 2011Browserscope oscon 2011
Browserscope oscon 2011lsimon
 
Managed Beans: When, Why and How
Managed Beans: When, Why and HowManaged Beans: When, Why and How
Managed Beans: When, Why and HowRussell Maher
 
How Oracle Integrates Accessibility into the Development Process
How Oracle Integrates Accessibility into the Development ProcessHow Oracle Integrates Accessibility into the Development Process
How Oracle Integrates Accessibility into the Development Process3Play Media
 
Optimus XPages: An Explosion of Techniques and Best Practices
Optimus XPages: An Explosion of Techniques and Best PracticesOptimus XPages: An Explosion of Techniques and Best Practices
Optimus XPages: An Explosion of Techniques and Best PracticesTeamstudio
 
IncQuery Server for Teamwork Cloud - Talk at IW2019
IncQuery Server for Teamwork Cloud - Talk at IW2019IncQuery Server for Teamwork Cloud - Talk at IW2019
IncQuery Server for Teamwork Cloud - Talk at IW2019Istvan Rath
 
Amazon CodeGuru - Automate Code review and Code performance monitoring
Amazon CodeGuru - Automate Code review and Code performance monitoringAmazon CodeGuru - Automate Code review and Code performance monitoring
Amazon CodeGuru - Automate Code review and Code performance monitoringOlawale Olaleye
 
Coded Automation and Autopilot.pptx
Coded Automation and Autopilot.pptxCoded Automation and Autopilot.pptx
Coded Automation and Autopilot.pptxZellAlfeche
 
Introduction to Protractor
Introduction to ProtractorIntroduction to Protractor
Introduction to ProtractorFlorian Fesseler
 
What is an Automation Framework ?
What is an Automation Framework ?�What is an Automation Framework ?�
What is an Automation Framework ?Sriram Angajala
 

Similar to Behaviour Driven Development - Cuking the Agile world (20)

How to Integrate UX and Agile
How to Integrate UX and AgileHow to Integrate UX and Agile
How to Integrate UX and Agile
 
Evolution and History of Angular as Web Development Platform.pdf
Evolution and History of Angular as Web Development Platform.pdfEvolution and History of Angular as Web Development Platform.pdf
Evolution and History of Angular as Web Development Platform.pdf
 
Accessibility Testing - Using Asqatasun - Meetup Webinar
Accessibility Testing - Using Asqatasun - Meetup WebinarAccessibility Testing - Using Asqatasun - Meetup Webinar
Accessibility Testing - Using Asqatasun - Meetup Webinar
 
Angular Meetup 1 - Angular Basics and Workshop
Angular Meetup 1 - Angular Basics and WorkshopAngular Meetup 1 - Angular Basics and Workshop
Angular Meetup 1 - Angular Basics and Workshop
 
India agile week chennai - Agile maturity to scale for enterprise & blendin...
India agile week   chennai - Agile maturity to scale for enterprise & blendin...India agile week   chennai - Agile maturity to scale for enterprise & blendin...
India agile week chennai - Agile maturity to scale for enterprise & blendin...
 
5 Best Automation Testing Tools to Speed up Testing.pdf
5 Best Automation Testing Tools to Speed up Testing.pdf5 Best Automation Testing Tools to Speed up Testing.pdf
5 Best Automation Testing Tools to Speed up Testing.pdf
 
Canada DevOps Summit 2020 Presentation Nov_03_2020
Canada DevOps Summit 2020 Presentation Nov_03_2020Canada DevOps Summit 2020 Presentation Nov_03_2020
Canada DevOps Summit 2020 Presentation Nov_03_2020
 
Unicom DevCon - CI/CD for Asp.net core apps using Docker
Unicom DevCon - CI/CD for Asp.net core apps using DockerUnicom DevCon - CI/CD for Asp.net core apps using Docker
Unicom DevCon - CI/CD for Asp.net core apps using Docker
 
Continuous delivery @ iyzico
Continuous delivery @ iyzicoContinuous delivery @ iyzico
Continuous delivery @ iyzico
 
Cucumber_Training_ForQA
Cucumber_Training_ForQACucumber_Training_ForQA
Cucumber_Training_ForQA
 
Browserscope oscon 2011
Browserscope oscon 2011Browserscope oscon 2011
Browserscope oscon 2011
 
Managed Beans: When, Why and How
Managed Beans: When, Why and HowManaged Beans: When, Why and How
Managed Beans: When, Why and How
 
How Oracle Integrates Accessibility into the Development Process
How Oracle Integrates Accessibility into the Development ProcessHow Oracle Integrates Accessibility into the Development Process
How Oracle Integrates Accessibility into the Development Process
 
Optimus XPages: An Explosion of Techniques and Best Practices
Optimus XPages: An Explosion of Techniques and Best PracticesOptimus XPages: An Explosion of Techniques and Best Practices
Optimus XPages: An Explosion of Techniques and Best Practices
 
IncQuery Server for Teamwork Cloud - Talk at IW2019
IncQuery Server for Teamwork Cloud - Talk at IW2019IncQuery Server for Teamwork Cloud - Talk at IW2019
IncQuery Server for Teamwork Cloud - Talk at IW2019
 
Amazon CodeGuru - Automate Code review and Code performance monitoring
Amazon CodeGuru - Automate Code review and Code performance monitoringAmazon CodeGuru - Automate Code review and Code performance monitoring
Amazon CodeGuru - Automate Code review and Code performance monitoring
 
Journey to the center of DevOps - v6
Journey to the center of DevOps - v6Journey to the center of DevOps - v6
Journey to the center of DevOps - v6
 
Coded Automation and Autopilot.pptx
Coded Automation and Autopilot.pptxCoded Automation and Autopilot.pptx
Coded Automation and Autopilot.pptx
 
Introduction to Protractor
Introduction to ProtractorIntroduction to Protractor
Introduction to Protractor
 
What is an Automation Framework ?
What is an Automation Framework ?�What is an Automation Framework ?�
What is an Automation Framework ?
 

Recently uploaded

Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 

Recently uploaded (20)

Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 

Behaviour Driven Development - Cuking the Agile world

  • 1. www.unicomlearning.com India Agile Week-2013 26-Oct-2013 at Pune BDD in an Agile world Gaurav Awasthi Senior Architect and Technology Evangelist www.agileinbusiness.com
  • 2. Concept, Practice, Tools www.unicomlearning.com Concept, Practice and finally Tools Concepts are beyond Practices and Tools Good Tools are better suited to Practices which help internalize Concepts quickly UNICOM Presents India Agile Week-2013
  • 3. The BDD World…  Concepts  Write software that matters  In close collaboration with Stakeholder  Practices  Writing features, scenarios  Write executable specs  Tools  Cucumber  JBehave  RSpecs UNICOM Presents India Agile Week-2013 www.unicomlearning.com
  • 4. BDD…by definition www.unicomlearning.com BDD is a second-generation, outside-in, multiple-stakeholder, high-automation, agile methodology. It describes a cycle of interactions with well-defined outputs, resulting in the delivery of working, tested software that matters. Dan North UNICOM Presents India Agile Week-2013
  • 5. Buzzword Agnostic Benefits… www.unicomlearning.com • Seamless mapping between Requirement statements and executable tests • Specification by example • Loose grammar of the domain • Brings Testers/QA to the forefront of development process • Self verifying documentation • Evolves behavior as the domain understanding changes UNICOM Presents India Agile Week-2013
  • 6. Co-existence with TDD Write a failing feature test BDD www.unicomlearning.com Write a failing unit test TDD Refactor TDD – Develop it the right way BDD – Develop the right thing UNICOM Presents India Agile Week-2013 Make the test pass
  • 7. And what about DDD ? • Domain Driven Design • Ubiquitous Language • gives vocabulary • Inside Out • Behavior Driven Development • Sentences out of the vocabulary • Description of the behavior • Outside In UNICOM Presents India Agile Week-2013 www.unicomlearning.com
  • 8. The BDD Practice www.unicomlearning.com 1. Describe the behavior in plain text – Features and Scenarios 2. Write a step definition for each Step 3. Run it and watch it fail 4. Write code to make the step pass 5. Run it again and see the step pass 6. Repeat step 2 – 5 until green like a Cuke 7. Repeat step 1 – 6 until the money runs out UNICOM Presents India Agile Week-2013
  • 9. The Tool - Cucumber Why Cucumber ? • one of the least technical tools • a very active open source project • supports a variety of languages UNICOM Presents India Agile Week-2013 www.unicomlearning.com
  • 10. Slicing Cucumber www.unicomlearning.com • JBehave -> ported to Ruby -> RBehave -> rewritten from scratch > RSpec -> + story runner -> Cucumber -> Cucumber-JVM • Aslak Hellesoy ported Cucumber to Java (cucumber-jvm) • Cucumber comes with Ruby (the original), Java, .NET, Adobe Flex, Python, Perl, Erlang, PHP • Full stack for acceptance tests include – Browser Driver and Browser UNICOM Presents India Agile Week-2013
  • 11. Gherkin www.unicomlearning.com • A Business Readable, Domain Specific Language that Cucumber understands • Line-based language that Cucumber uses to define behaviors in the form of features, scenarios, and steps • Serves 3 purposes : • • • Automated Tests Documentation Specs for Code to be written • Source files have .feature extension. Single Gherkin source file contains a description of a single feature UNICOM Presents India Agile Week-2013
  • 12. Gherkin syntax Feature : title www.unicomlearning.com  As a [ person or role who will benefit ]  I want [ some feature ]  So that [ benefit or value of the feature ] UNICOM Presents India Agile Week-2013
  • 13. Gherkin syntax Scenario : title  Given [ some initial context ]  When [ an event occurs]  Then [ ensures some outcome ] UNICOM Presents India Agile Week-2013 www.unicomlearning.com
  • 14. Example Feature: Customer purchases a device • As a Customer • I want to purchase a Bluetooth device • So that I can make or receive a hands free call www.unicomlearning.com Scenario : Customer has a credit note valued more than the receipt amount • Given the customer is on the till • And he has a credit note of Rs 1000 • And the receipt amount is Rs 500 • When the balance amount is paid • Then the billing completes UNICOM Presents India Agile Week-2013
  • 15. Cucumber Options @RunWith(Cucumber.class) @Cucumber.Options ( tags = “@focus”, features= “classpath:billing.feature” ) public class CukeRunner { } Some common options : • features – path to the feature files • glue – where to look for step definition and hooks • tags – what tags in the features should be executed • format – what formatters to use • … UNICOM Presents India Agile Week-2013 www.unicomlearning.com
  • 16. CLI Option www.unicomlearning.com • Several Runners • • • Command Line Interface JUnit Runner Android Runner cucumber-core cucumber-junit cucumber-android • java cucumber.cli.Main [options] [FILE|DIR] • --glue , --format, --tags, --name … • Benefit : • • Independent of JUnit Integration with Ant UNICOM Presents India Agile Week-2013
  • 17. Demo Code • Create a maven project, with cucumber-jvm related dependencies • • Feature: Withdrawing money from a User account • Scenario: Withdrawing money from a User's account should reduce money in the current balance • Given a User has $100 in his account • When $50 is withdrawn from the account • Then the balance should be $50 Write Java wrapper class – like CukeRunner, • • • • cucumber-core, cucumber-java, cucumber-junit Write a Feature and a scenario with steps • • www.unicomlearning.com annotated with RunWith and Cucumber.Options Run the class, let it fail Implement Steps, Run again See it green like a cuke UNICOM Presents India Agile Week-2013
  • 18. And the debate www.unicomlearning.com To TDD, To BDD or To prefer one over the other UNICOM Presents India Agile Week-2013
  • 19. References • • • • • www.unicomlearning.com That's not BDD, that's just Cucumber by Chris Parsons Introducing BDD by Dan North http://dannorth.net/whats-in-a-story/ by Dan North http://cukes.info/install-cucumber-jvm.html http://cukes.info/api/cucumber/jvm/javadoc/cucumber/api/junit/C ucumber.Options.html UNICOM Presents India Agile Week-2013
  • 20. www.unicomlearning.com Speaker name: Gaurav Awasthi Email ID: gawasthi22@gmail.com India Agile Week-2013 Organized by UNICOM Trainings & Seminars Pvt. Ltd. contact@unicomlearning.com

Editor's Notes

  1. What TDD does, its explanation, what it doesn’t do, and how BDD fits in
  2. Why Cucumber – least technical, very active open source project, supports variety of language