Specification by example
What’s the problem?
Accidental Adversaries
Useless Crap
Business Failure Useless Crap
Business Failure Useless Crap Maintenance Nightmare
Business Failure Business Success Useless Crap Maintenance Nightmare
Specification by example Business Failure Business Success Specification by example Useless Crap Maintenance Nightmare
Specification by example
Deriving scope from goals
Derive the scope: User Stories
Specify collaboratively
Refining the specification
Refining the specification “Specifications with examples are acceptance tests” Gojko Adzic Be sure spec is testable Focus on business functionality not design Avoid UI details Avoid covering every possible combination
Refining the specification Illustrating by examples Feature: Free delivery In order to save money As a VIP customer I want the system to offer free delivery on certain items to me
Refining the specification In order to minimize the chances of misunderstanding, we write scripts in terms of Given -> When -> Then. Scenario: Free delivery Given I am a VIP customer And I am on product detail page And There are only books in my shopping cart And There are <= 10 books in my shopping cart And I have added 'ABC Press' book to my shopping cart When I press 'Go to checkout' button And I have chosen 'Moscow' in 'Ship To' dropdown Then I can choose free delivery
Automating examples Start small Select important examples for automation Plan up-front to automate Avoid using pre-populated data Refactor your tests from time to time Validate frequently
Living documentation Keep specifications short Evolve specifications Make documentation accessible Organize the documentation Put specifications under version control