www.unicomlearning.com

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

BDD in an Agile world
Gaurav Awasthi
Senior Architect a...
Concept, Practice, Tools

www.unicomlearning.com

Concept, Practice and finally Tools
Concepts are beyond Practices and ...
The BDD World…
 Concepts
 Write software that matters
 In close collaboration with Stakeholder

 Practices
 Writing f...
BDD…by definition

www.unicomlearning.com

BDD is a second-generation,
outside-in,
multiple-stakeholder,
high-automation,
...
Buzzword Agnostic Benefits…

www.unicomlearning.com

• Seamless mapping between Requirement statements and
executable test...
Co-existence with TDD
Write a failing
feature test

BDD

www.unicomlearning.com

Write a
failing unit
test
TDD

Refactor
T...
And what about DDD ?
• Domain Driven Design
• Ubiquitous Language
• gives vocabulary
• Inside Out

• Behavior Driven Devel...
The BDD Practice

www.unicomlearning.com

1. Describe the behavior in plain text – Features and Scenarios
2. Write a step ...
The Tool - Cucumber
Why Cucumber ?
• one of the least technical tools
• a very active open source project
• supports a var...
Slicing Cucumber

www.unicomlearning.com

•

JBehave -> ported to Ruby -> RBehave -> rewritten from scratch > RSpec -> + s...
Gherkin

www.unicomlearning.com

• A Business Readable, Domain Specific Language that
Cucumber understands
• Line-based la...
Gherkin syntax
Feature : title

www.unicomlearning.com

 As a [ person or role who will benefit ]
 I want [ some feature...
Gherkin syntax
Scenario : title
 Given [ some initial context ]
 When [ an event occurs]
 Then [ ensures some outcome ]...
Example
Feature: Customer
purchases a device
• As a Customer
• I want to purchase a Bluetooth
device
• So that I can make ...
Cucumber Options
@RunWith(Cucumber.class)
@Cucumber.Options (
tags = “@focus”,
features= “classpath:billing.feature”
)
pub...
CLI Option

www.unicomlearning.com

• Several Runners
•
•
•

Command Line Interface
JUnit Runner
Android Runner

cucumber-...
Demo Code
•

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

•

Feature: Withdrawing money from a User a...
And the debate

www.unicomlearning.com

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

UNICOM Presents

India Agile Week-...
References
•
•
•
•
•

www.unicomlearning.com

That's not BDD, that's just Cucumber by Chris Parsons
Introducing BDD by Dan...
www.unicomlearning.com

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

India Agile Week-2013
Organized by
UN...
Upcoming SlideShare
Loading in …5
×

Behaviour Driven Development - Cuking the Agile world

2,077
-1

Published on

This slide deck is what I spoke on in Agile India week conference in Oct 2013 at Pune

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
2,077
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
63
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide
  • What TDD does, its explanation, what it doesn’t do, and how BDD fits in
  • Why Cucumber – least technical, very active open source project, supports variety of language
  • Behaviour Driven Development - Cuking the Agile world

    1. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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
    1. A particular slide catching your eye?

      Clipping is a handy way to collect important slides you want to go back to later.

    ×