Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Cucumber: Bridging Communication Gaps with Deve...

Cucumber: Bridging Communication Gaps with Developers and Stakeholders

Cucumber is a behavior-driven testing framework that allows development teams to describe how software should behave in plain english. Writing features in Cucumber aligns well with Agile and Scrum teams. User stories in Agile or story points in Scrum follow the same plain language rules as Cucumber and can be a large benefit to help improve collaboration between technical and non-technical users. This session will cover:

• how to correctly describe an applications behavior using Cucumber syntax & vocabulary
• writing scenarios, features, and step definitions
• the pitfalls of writing poor Cucumber features
• collaboration benefits between technical and non-technical team members
• 5 quick ideas to help you convince stakeholders to write your features for you

Bermon Painter

February 27, 2014
Tweet

More Decks by Bermon Painter

Other Decks in Programming

Transcript

  1. The hardest single part of building a software system is

    deciding precisely what to build. ! - Fred Brooks
  2. Overview OUTLINE UNIT TESTS vs. ACCEPTANCE TESTS Workflow FEATURES, SCENARIOS,

    & STEPS Step Definitions VERIFY ACCEPTANCE CRITERIA Benefits & Best Practices WRITING FEATURES & IMPROVING COLLABORATION Convincing Stakeholders 5 WAYS TO CONVINCE STAKEHOLDERS TO WRITE FEATURES
  3. Unit Tests UNIT TESTS vs. ! ACCEPTANCE TESTS ENSURE YOU

    BUILD THE THING RIGHT Acceptance Tests ENSURE YOU BUILD THE RIGHT THING
  4. FEATURE FILES Feature: Feedback when entering invalid credit card details

    ! In user testing we've seen a lot of people who made mistakes entering their credit card. We need to be as helpful as possible here to avoid losing users at this crucial stage of the transaction. ! Scenario: Credit card number too short Given I have chosen some items to buy
 And I am about to enter credit card info
 When I enter a card number that's only 15 digits long
 And all the other details are correct
 And I submit the form
 Then the form should be redisplayed
 And I should see a message advising me of the correct number of digits
  5. FEATURE FILES Feature: … ! Scenario: … Given: … And:

    … When: … Then: … And: … Features EACH FEATURE FILE BEGINS WITH A FEATURE IN ORDER TO PROVIDE A DESCRIPTIVE SUMMARY. ! FEATURE DESCRIPTIONS PROVIDE CONTEXT.
  6. FEATURE FILES Feature: … ! Scenario: … Given: … And:

    … When: … Then: … But: … Scenarios SCENARIOS PROVIDE AN EXAMPLE OF HOW THE SYSTEM SHOULD BEHAVE.
  7. FEATURE FILES Feature: … ! Scenario: … Given: … And:

    … When: … Then: … But: … Steps WRITTEN IN PLAIN ENGLISH. STEPS WILL MAKE UP THE MAJORITY OF A FEATURE FILE.
  8. FEATURE FILES Feature: … ! Scenario: … Given: … And:

    … When: … Then: … But: … Steps GIVEN: SETUP
  9. FEATURE FILES Feature: … ! Scenario: … Given: … And:

    … When: … Then: … But: … Steps GIVEN: SETUP ! WHEN: ACTIONS ! THEN: ASSERTIONS
  10. FEATURE FILES Feature: … ! Scenario: … Given: … And:

    … When: … Then: … But: … Steps GIVEN: SETUP ! WHEN: ACTIONS ! THEN: ASSERTIONS ! AND/BUT: HELPERS
  11. FEATURE FILES Feature: Feedback when entering invalid credit card details

    ! In user testing we've seen a lot of people who made mistakes entering their credit card. We need to be as helpful as possible here to avoid losing users at this crucial stage of the transaction. ! Scenario: Credit card number too short Given I have chosen some items to buy
 Given I am about to enter credit card info
 Given I enter a card number that's only 15 digits long
 Given all the other details are correct
 Given I submit the form
 Given the form should be redisplayed
 Given I should see a message advising me of the correct number of digits
  12. FEATURE FILES Feature: Feedback when entering invalid credit card details

    ! In user testing we've seen a lot of people who made mistakes entering their credit card. We need to be as helpful as possible here to avoid losing users at this crucial stage of the transaction. ! Scenario: Credit card number too short * I have chosen some items to buy
 * I am about to enter credit card info
 * I enter a card number that's only 15 digits long
 * all the other details are correct
 * I submit the form
 * the form should be redisplayed
 * I should see a message advising me of the correct number of digits
  13. STEP DEFINITIONS Feature: Feedback when entering invalid credit card details

    ! Given /I have chosen some items to buy/ do
 # CODE GOES HERE end ! When /I enter a card number that's only 15 digits long/ do
 # CODE GOES HERE end ! And /all the other details are correct/ do
 # CODE GOES HERE end ! And /I submit the form/ do
 # CODE GOES HERE end ! Then /the form should be redisplayed/ do
 # CODE GOES HERE end
  14. 1. Describe Behaviors (STAKEHOLDER + TEAM) ! 2. Write Step

    Definitions (DEVELOPERS) ! 3. Run Tests (TESTS FAIL) ! 4. Write Code for Tests to Pass ! 5. Run Tests (TESTS PASS) FAIL PASS REFACTOR
  15. You should not be afraid to delete tests that are

    no longer providing value, no matter whether you originally planned to keep them or not. We tend to treat tests as these holy creatures that live blameless, irreproachable lives once they have sprung into existence. ! Not so. ! The maintenance required to keep a test running weighs against its value in further development. Sometimes these lines cross, and the test simply becomes a burden on the project. Having the skill and experience to recognize a burdensome test is something we should be bringing to our clients, as well as the fortitude to rewrite it, rethink it, or delete it. ! - Adam Milligan