Elaborate with Scenarios

Add scenarios to each feature in order to:

  • Elicit additional expectations from product owners
  • Uncover unknowns before work is accepted in a sprint
  • Communicate to developers what needs to be implemented
  • Demonstrate software meets acceptance criteria
  • Provide a foundation for change orders
  • Eventually, create automated tests

When to elaborate

  • Important scenarios sometimes written alongside features
  • Most detail is usually added after a feature is chosen for implementation
  • Too much detail may bog down understanding of full scope
  • Why detail something that may never be built?

What to describe

  • Don’t try to test every permutation
  • Cover valuable paths
  • The happy paths: When the user does what you want them to
  • The less happy paths: When you need to direct the user to do something else
    • A required field was left blank
    • Data was entered in an unexpected format
    • Terms of service weren’t accepted
    • A search returns no results

Who elaborates?

  • Elaboration is a collaboration between:
    • Project managers
    • Product owners
    • Developers
    • Testers
  • Emphasize providing:
    • Enough guidance for developers
    • Enough flexibility for implementation
    • Keep it flexible
    • Avoid implementation details
    • Don’t try to stuff it into pre-existing steps

Gherkin Scenario Format

Given: Defines the initial state of the system for the scenario

Given I am on the homepage

When: Describes the action performed on the system

When I press "Log in"

Then: Describes the system state after the action has been performed

Then I should see "Username field is required"

And, But: Can be added to any of the above

And I should see "Password field is required"
  • Each line is called a Step
  • Each step is supported by PHP code

The whole feature

features/login.feature

Feature: Maintain content
  In order to maintain site content
  As an editor
  I need to log in

  Scenario: Enter valid username and password // Happy path
    Given I am on the homepage
    When I fill in "admin" for "Username"
    And I fill in "admin" for "Password"
    And I press "Log in"
    Then I should see "Add content"

  Scenario: Fail to enter username or password // Less happy path
    Given I am on the homepage
    When I press "Log in"
    Then I should see "Username field is required"
    And I should see "Password field is required"

Scenario Style

  • Every scenario is indendent
  • Always from perspecitve of the role identified in the feature
  • No more than 6 - 8 scenarios per feature
  • One Given: Set the scene
  • One When: Change the scene
  • One Then: Observe the outcome
  • Each with as many Ands or Buts as needed

Example

Once a step definition is written in PHP, the step can be re-used:

Scenario: Access free content
  Given I am on "/series/learning-sass-and-compass"
  When I follow "What is a CSS Preprocessor?"
  Then I should see "What is a CSS Preprocessor?"
  And I should see "Interactive Transcripts"
_images/dm-teasers.png

Table Of Contents

Previous topic

Gherkin Feature Stanzas

Next topic

The Drupal Extension

This Page