Skip to content

Effective BDD Scenarios

Status: Placeholder - Content coming soon

Prerequisites: Your First Specification, TDD with Specifications

Planned Content

This tutorial teaches advanced BDD techniques including Example Mapping for specification discovery, writing effective scenarios, and avoiding common anti-patterns.

What You'll Learn

  • Discover specifications through Example Mapping workshops
  • Write concrete, independent, and focused scenarios
  • Avoid BDD anti-patterns (imperative, vague, interdependent)
  • Refactor specifications for clarity
  • Use scenario outlines for data-driven tests
  • Organize scenarios effectively
  • Review and iterate on specifications

Tutorial Structure

  1. Example Mapping technique
  2. Collaborative discovery workshop
  3. User story → Rules → Examples → Questions
  4. Color-coded cards (story, rules, examples, questions)
  5. Facilitation techniques

  6. Example Mapping workshop

  7. Exercise: Map a user story
  8. Identify rules and edge cases
  9. Convert examples to scenarios
  10. Resolve questions with stakeholders

  11. Writing effective scenarios

  12. CONCRETE: Specific values, not abstractions
  13. INDEPENDENT: No order dependencies
  14. FOCUSED: One behavior per scenario
  15. DECLARATIVE: What, not how

  16. Common anti-patterns to avoid

  17. Imperative scenarios (UI-focused)
  18. Vague scenarios (lacking specifics)
  19. Interdependent scenarios (order matters)
  20. Overly complex scenarios (too many steps)

  21. Scenario outlines

  22. Data-driven testing with Examples table
  23. When to use outlines vs. separate scenarios
  24. Keeping outlines readable

  25. Refactoring specifications

  26. Extract common setup to Background
  27. Split complex scenarios
  28. Improve step clarity
  29. Remove duplication

  30. Organizing scenarios

  31. Group by Rules
  32. Name scenarios descriptively
  33. Order: happy path → edge cases → error cases
  34. File organization strategies

  35. Review and iteration

  36. Specification review checklist
  37. Collaborate with stakeholders
  38. Refine based on feedback
  39. Keep specifications living documents

Example Mapping Exercise

The tutorial includes a complete Example Mapping session:

User Story:

As a customer
I want to apply discount codes to my order
So that I can save money on purchases

Rules discovered: - Discount codes must be valid and not expired - Only one discount code per order - Discount applies before tax - Some products excluded from discounts

Examples (become scenarios): - Valid code with 20% discount → price reduced - Expired code → error message - Apply second code → first code removed - Discount on excluded product → discount not applied

Questions: - Can codes be combined? (No → Rule) - What if code format is invalid? (Error → Scenario)

Scenario Quality Checklist

Good scenarios are: - [ ] Concrete (specific values) - [ ] Independent (any order) - [ ] Focused (one behavior) - [ ] Declarative (what, not how) - [ ] Readable (business language) - [ ] Valuable (demonstrate requirement)

Key Concepts Covered

  • Example Mapping facilitation
  • Scenario quality characteristics
  • BDD anti-patterns
  • Scenario outlines for data-driven tests
  • Specification refactoring
  • Collaborative discovery

Before and After Examples

BEFORE (Poor scenario):

Scenario: Discounts work
  Given there are discounts
  When I use one
  Then it works

AFTER (Effective scenario):

Scenario: Apply 20% discount to eligible order
  Given I have items worth $100.00 in my cart
  And I have a valid discount code "SAVE20" for 20% off
  When I apply the discount code
  Then my subtotal should be $80.00
  And my total including tax should be $96.00

Scenario Outline Example

Rule: Different discount types calculate correctly

  Scenario Outline: Apply discount to order
    Given I have items worth $<subtotal> in my cart
    And I have a discount code for <discount>% off
    When I apply the discount code
    Then my discounted subtotal should be $<discounted>

    Examples:
      | subtotal | discount | discounted |
      | 100.00   | 10       | 90.00      |
      | 100.00   | 20       | 80.00      |
      | 100.00   | 50       | 50.00      |
      | 50.00    | 20       | 40.00      |

Best Practices

  • Use Example Mapping before writing specifications
  • Write scenarios in business language
  • Keep scenarios short (< 10 steps)
  • Use Background for common setup
  • Review specifications with stakeholders
  • Refactor specifications like code
  • Make scenarios executable

Tools and Techniques

  • Example Mapping (sticky notes or digital)
  • Scenario quality checklist
  • Specification review sessions
  • Living documentation
  • Scenario refactoring patterns

Next Steps

After completing this tutorial, you'll write high-quality specifications. Explore other specialized topics based on your needs: Architecture Documentation, Security Scanning, or TypeScript Setup.


Tutorials | How-to Guides | Explanation | Reference

You are here: Tutorials — learning-oriented guides that take you through steps to complete a project.