Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Agile DC 2016 Behavior Driven Development Workshop

383 views

Published on

Behavior Driven Development / Acceptance Test Driven Development (BDD/ATDD) is a new, exciting approach to developing software that has been shown to reduce rework and increase customer satisfaction. While other testing tools focus primarily on “are we building the thing right?”, BDD tools such as Cucumber and SpecFlow attack the problem of software directly at its source: “are we building the right thing?” By retaining all the benefits of automated unit testing, while extending them upstream to cover requirements, we cut the Gordian knot of risk and complexity to unleash hyper-productivity.

Published in: Software
  • Be the first to comment

  • Be the first to like this

Agile DC 2016 Behavior Driven Development Workshop

  1. 1. 1 Behavior Driven Development Workshop Craeg Strong CTO, Ariel Partners October 24, 2016 Washington, DC © Copyright Ariel Partners 2016 *sales@arielpartners.com ((646) 467-7394
  2. 2. 2 Software Development since 1988 Large Commercial & Government Projects Agile Coach / DevOps Engineer Kanban Trainer / SpecFlow Trainer Performance & Scalability Architect Certified Ethical Hacker New York & Washington DC Area CTO, Ariel Partners AKT, CSM, CSP, CSD, CSPO, PSM, ITILv3, PMI-ACP, PMP, LeSS, SAFe www.arielpartners.com cstrong@arielpartners.com @ckstrong1 Craeg Strong © Copyright Ariel Partners 2016 *sales@arielpartners.com ((646) 467-7394
  3. 3. 3 Agenda • Context & Background • Benefits of BDD • Good vs Bad Gherkin Demonstration • Bad Gherkin Team Review & Discussion • Whirlwind Tour of Tools & Reports • Gherkin Writing Workshop • Group Discussion © Copyright Ariel Partners 2016 *sales@arielpartners.com ((646) 467-7394
  4. 4. 4 Supplies Needed 1. 2+ Rolls of Scotch Transparent Tape 2. 6+ Pads of Large Size Post-It Notes 3. A Dozen or more Sharpies 4. 1-2 Post-It Self-Stick Easel Pads 25” x 30.5” © Copyright Ariel Partners 2014 *sales@arielpartners.com ((646) 467-7394
  5. 5. 5 Where Does BDD Fit In? © Copyright Ariel Partners 2016 *sales@arielpartners.com ((646) 467-7394 Useful Techniques Story Mapping BDD: Specification By Example Impact Mapping Visioning / Ideation Workshops GOOTB Mockups Wireframes Journey Mapping
  6. 6. 6 When Do Organizations Switch To BDD? • New to scrum, need help with understanding how to create useful Acceptance Test Criteria • Converting a legacy Microsoft VB application to .NET • Government project without enough testing, need to beef up testing capabilities • Mostly manual testing, spreadsheets, looking for a better way • Automated GUI Tests Brittle, Hard To Maintain © Copyright Ariel Partners 2016 *sales@arielpartners.com ((646) 467-7394
  7. 7. 7 What Problems Can BDD Solve? qEnsure what is to be delivered is actually required qEnsure what is to be delivered is valuable to the business qEnsure what is to be delivered is within the agreed scope of functionality qEnsure what is to be delivered is well understood by the team © Copyright Ariel Partners 2016 *sales@arielpartners.com ((646) 467-7394 ü Clearly specify the required behavior of each software component ü in everyday common business language ü that anyone in the team (including business stakeholders) can understand ü And then enforce those rules via tests How?
  8. 8. 8 Who Is Involved? The Three Amigos © Copyright Ariel Partners 2016 *sales@arielpartners.com ((646) 467-7394 public void CalculateDiscount(Order order) { if (order.Customer.IsNew) order.FinalAmount = Math.Round(order.Total * 9/10); } Register as “bart_bookworm” Go to “/catalog/search” Enter “ISBN-0955683610” Click “Search” Click “Add to Cart” Click “View Cart” Verify “Subtotal” is “$33.75” We would like to encourage new users to buy in our shop. Therefore we offer 10% discount for their first order. Analyst Developer Tester
  9. 9. 9 Specification Workshops © Copyright Ariel Partners 2016 *sales@arielpartners.com ((646) 467-7394 Given the user has not ordered yet When the user adds a book with the price of EUR 37.5 into the shopping cart Then the shopping cart sub-total is EUR 33.75. We would like to encourage new users to buy in our shop. Therefore we offer 10% discount for their first order. Analyst Developer Tester Gherkin
  10. 10. 10 Gherkin: The Language of BDD © Copyright Ariel Partners 2016 *sales@arielpartners.com ((646) 467-7394 Scenario Given [Context] And [More Context] When (<role> does) [Action] And [Other Action] Then (<role> should see) [Outcome] And [More Outcomes] Scenarios = Test Cases = Acceptance Criteria
  11. 11. 11 Good Gherkin versus Bad Gherkin © Copyright Ariel Partners 2016 *sales@arielpartners.com ((646) 467-7394 VS.
  12. 12. 12 Bad versus Good Gherkin © Copyright Ariel Partners 2016 *sales@arielpartners.com ((646) 467-7394 Happy Path Should be First Boundary condition does not match scenario Show me, don’t tell me. Should be an example GUI Display Detail makes this brittle. What if we change it to a bar chart? This data is already grouped. Use the user’s language not technical language More GUI Details, not necessary ?Why Different?
  13. 13. 13 Bad versus Good Gherkin (Printout) © Copyright Ariel Partners 2016 *sales@arielpartners.com ((646) 467-7394
  14. 14. 14 Characteristics of Good Gherkin Specifications • Use Domain Language (Problem Space) not Technical Language (Solution Space) • Tangible, not Abstract • Explicit, not Implicit • No Extraneous information • Human Readable, no “magic numbers” • Avoid GUI-Specific terms (e.g. “button”, “screen”, “click”) • Look For Reusable Phrases © Copyright Ariel Partners 2016 *sales@arielpartners.com ((646) 467-7394
  15. 15. 15 Scenario Outline Style-Gherkin © Copyright Ariel Partners 2016 *sales@arielpartners.com ((646) 467-7394 Feature: Shipping cost calculation Scenario Outline: Calculate shipping costs Given I have <books> books in my basket And my shipping address is in <region> When I start the checkout process Then the shipping costs should be EUR <cost> Examples: | case | books | region | cost | | single book to EU | 1 | Europe | 7 | | two books to EU | 2 | Europe | 9 | | single book to US | 1 | US | 12 | @edge-case Examples: Edge cases | case | books | region | cost | | too many books | 10000 | Europe | 20005 | | zero books | 0 | Europe | 0 |
  16. 16. 16 Bad Gherkin: Team One © Copyright Ariel Partners 2016 *sales@arielpartners.com ((646) 467-7394
  17. 17. 17 Bad Gherkin: Team Two © Copyright Ariel Partners 2016 *sales@arielpartners.com ((646) 467-7394
  18. 18. 18 Bad Gherkin: Team Three © Copyright Ariel Partners 2016 *sales@arielpartners.com ((646) 467-7394
  19. 19. 19 Bad Gherkin: Team Four © Copyright Ariel Partners 2016 *sales@arielpartners.com ((646) 467-7394
  20. 20. 20 BDD cuts the Gordian knot © Copyright Ariel Partners 2016 *sales@arielpartners.com ((646) 467-7394 Unit Tests As Needed Automated Acceptance Tests (BDD) Automated GUI Tests Manual Exploratory Testing
  21. 21. 21 Features Versus User Stories © Copyright Ariel Partners 2016 *sales@arielpartners.com ((646) 467-7394 1. Manual Entry of Email 2. Dropdown 4. Type- Ahead 3. Don’t Show My Email
  22. 22. 22 Feature File BDD With SpecFlow 1. Write Feature Step Definitions 2. Generate Template 3. Fill In Code © Copyright Ariel Partners 2016 *sales@arielpartners.com ((646) 467-7394
  23. 23. 23 Functional Coverage Report q All system functions expressed as features, split into user stories q All user stories have acceptance criteria q Each criterion translated to an automated test using structured English (Gherkin) q Customized report matches epics and user stories to automated acceptance tests q Test fails unless software is implemented correctly Links to Feature Documentation Generated via Pickles © Copyright Ariel Partners 2016 *sales@arielpartners.com ((646) 467-7394
  24. 24. 24 Generating Documentation From Specifications © Copyright Ariel Partners 2016 *sales@arielpartners.com ((646) 467-7394
  25. 25. 25 Combined Report © Copyright Ariel Partners 2016 *sales@arielpartners.com ((646) 467-7394 Page One Page Two
  26. 26. 26 Different flavors of BDD © Copyright Ariel Partners 2016 *sales@arielpartners.com ((646) 467-7394 External Specification Maintained Outside of Code Base Code Base Application Excel Sheet Wiki Page Textual Specification Maintained Within Code Base Code Base Specification Captured Directly In Source Code Code Base
  27. 27. 27 Gherkin Exercise: Team One © Copyright Ariel Partners 2016 *sales@arielpartners.com ((646) 467-7394 As a user I want to input my feedback So that I can recognize a co-worker for their actions Acceptance Criteria • Both sender and receiver email must be filled in • One Corporate value (e.g. Integrity, Commitment, Courage, Excellence) must be filled in • A short, optional description may be filled in • I need to be able recognize someone even if they are not registered with the recognition system Key Examples • Leonard.mccoy@email.com recognizes an existing user spock@email.com for Integrity • Anthony.bourdain@email.com recognizes a new user andrew.zimmern@email.com for Commitment Create Recognition
  28. 28. 28 Gherkin Exercise: Team One (Hints) © Copyright Ariel Partners 2016 *sales@arielpartners.com ((646) 467-7394
  29. 29. 29 Gherkin Exercise: Team Two © Copyright Ariel Partners 2016 *sales@arielpartners.com ((646) 467-7394 As a manager I want the system to limit the number of times per week a user can recognize a co-worker So that a recognition is seen as valuable Acceptance Criteria • To send a recognition, both sender and receiver email must be filled in • To send a recognition, one Corporate value (e.g. Integrity, Commitment, Courage, Excellence) must be filled in • For each recognition, a short, optional description may be filled in • If a user has sent three recognitions this week, system should prevent user from entering a fourth Key Examples Limit Recognitions Per Week Sender Receiver Corporate Value Date Result Tom.Cruise@email.org Johnny.depp@email.org Commitment Monday 17 Oct 2016 ok Tom.Cruise@email.org Leonardo.DiCaprio@email.org Integrity Wed 19 Oct 2016 ok Tom.Cruise@email.org Brad.Pitt@email.org Respect Thur 20 Oct 2016 ok Tom.Cruise@email.org Robert.DowneyJr@email.org Courage Fri 21 Oct 2016 error
  30. 30. 30 Gherkin Exercise: Team Two (Hints) © Copyright Ariel Partners 2016 *sales@arielpartners.com ((646) 467-7394
  31. 31. 31 Gherkin Exercise: Team Three © Copyright Ariel Partners 2016 *sales@arielpartners.com ((646) 467-7394 As an administrator I want to maintain the set of corporate values for which a user can recognize a peer So that our corporate culture is aligned with the values we espouse Acceptance Criteria • Each corporate value consists of a one or two word title and a brief description • There must never be less than two corporate values • If a previously-existing corporate value is removed, existing recognitions are unaffected, but no new recognitions can be added with the removed corporate value Key Examples Maintain Corporate Values Corporate Value Description Integrity Always act honestly, ethically, and do the right thing even when it hurts Commitment Committed to the long term success and happiness of our customers, our people, and our partners Courage To take on difficult challenges, to accept new ideas, to accept incremental failure Excellence Always strive to exceed expectations and continuously improve
  32. 32. 32 Gherkin Exercise: Team Three (Hints) © Copyright Ariel Partners 2016 *sales@arielpartners.com ((646) 467-7394
  33. 33. 33 Gherkin Exercise: Team Four © Copyright Ariel Partners 2016 *sales@arielpartners.com ((646) 467-7394 As a user I want to see the most recent recognitions So that I can stay informed of the recognitions my peers are receiving Acceptance Criteria • Home page should display a list of all recognitions in the system • Each recognition should list the sender email, receiver email, corporate value, and date sent • The list of recognitions should show the most recent first, like the facebook feed • A user should be able to sort any column • A user should be able to show only recognitions for a particular corporate value (filter by corporate value) Key Examples Recognition Feed Sender Receiver Corporate Value Date Jaqen.Hghar@got.org Arya.Stark@got.org Excellence 10/12/2016 Jaqen.Hghar@got.org Arya.Stark@got.org Excellence 9/27/2016 Petyr.Baelish@got.org Sansa.Stark@got.org Courage 10/22/2016 Jaime.Lannister@got.org Cersei.Lannister@got.org Commitment 6/1/2016
  34. 34. 34 Gherkin Exercise: Team Four (Hints) © Copyright Ariel Partners 2016 *sales@arielpartners.com ((646) 467-7394
  35. 35. 35 Team Discussions, Q & A © Copyright Ariel Partners 2016 *sales@arielpartners.com ((646) 467-7394 Craeg Strong Savant Financial Technologies, Inc. d/b/a Ariel Partners Cell: (917) 992-0259 cstrong@arielpartners.com www.arielpartners.com @arielpartners Thank You! Helpful Links Gherkin Documentation: http://docs.behat.org/en/v2.5/guides/1.gherkin.html Cucumber (Java, PHP, Ruby, etc): https://cucumber.io/ Cucumber (JavaScript): https://www.npmjs.com/package/cucumber Specflow (.NET): http://www.specflow.org/ Pickles Documentation: http://www.picklesdoc.com/ CucumberJS Reports: https://www.npmjs.com/package/cucumber-html-reporter …many more...
  36. 36. 36 Advantages of BDD Approach © Copyright Ariel Partners 2016 *sales@arielpartners.com ((646) 467-7394 Improves Software Quality q Helps develop frugal, effective and testable software q Answers: what functions are well-covered? Where do we have exposure? Makes Writing Tests Easier q many convenience functions q pre-integrated with powerful libraries like NUnit and Selenium Encourages Collaboration q Encourages tester, analyst and developer to sync up q Captures information that might otherwise be lost Facilitates Communication q Way for Product Owners to provide concrete examples q Easy to define boundary conditions Documentation and Reporting q Requirements Traceability? Yup. q Functional Coverage? Yup. Are we building right thing? q Did we “answer the mail”? q Validates that the software meets the requirements

×