Specification by Example
Upcoming SlideShare
Loading in...5
×
 

Specification by Example

on

  • 39,558 views

An introduction to Specification by Example.

An introduction to Specification by Example.

Statistics

Views

Total Views
39,558
Views on SlideShare
39,505
Embed Views
53

Actions

Likes
31
Downloads
425
Comments
2

4 Embeds 53

http://www.scoop.it 44
https://twitter.com 5
http://www.linkedin.com 3
https://www.linkedin.com 1

Accessibility

Categories

Upload Details

Uploaded via as Apple Keynote

Usage Rights

CC Attribution License

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel

12 of 2

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
  • really useful presentation. Thanks!
    Are you sure you want to
    Your message goes here
    Processing…
  • This is awesome presentation !!
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n

Specification by Example Specification by Example Presentation Transcript

  • Specification By Example My role in ATDD BDD, ATDD Declan Whelan @dwhelan
  • What’s the Problem?
  • Waterfall Winston Royce, 1970Source: http://www.cs.umd.edu/class/spring2003/cmsc838p/Process/waterfall.pdf
  • Cost Of Change We add formal handoffs. Documents for handoffs. Documents reviews. Review committees. Document templates. Cost% Standards. Of%Change% Time%
  • Traditional Flow
  • Traditional FlowSpecification
  • Traditional Flow BuildSpecification
  • Traditional Flow BuildSpecification Tests Cases
  • Traditional Flow BuildSpecification Test Tests Cases
  • Traditional Flow BuildSpecification Test Deploy Tests Cases
  • We Found a Bug! How did QA miss this? That was obvious! I shouldnt Developers dont test before have to spell out every they throw it over the wall! detail! Exec TesterProductManager We did what was in functional spec! Business requirements werent clear! BA missed it in the technical requirements! Dev BA Architect
  • We Found a Bug! How did QA miss this? That was obvious! I shouldnt Developers dont test before have to spell out every they throw it over the wall! detail! Exec TesterProductManager We did what was in functional spec! Business requirements werent clear! BA missed it in the technical requirements! Dev BA Architect
  • We Found a Bug! How did QA miss this? That was obvious! I shouldnt Developers dont test before have to spell out every they throw it over the wall! detail! Exec TesterProductManager We did what was in functional spec! Business requirements werent clear! BA missed it in the technical requirements! Dev BA Architect
  • We Found a Bug! How did QA miss this? That was obvious! I shouldnt Developers dont test before have to spell out every they throw it over the wall! detail! Exec TesterProductManager We did what was in functional spec! Business requirements werent clear! BA missed it in the technical requirements! Dev BA Architect
  • We Found a Bug! How did QA miss this? That was obvious! I shouldnt Developers dont test before have to spell out every they throw it over the wall! detail! Exec TesterProductManager We did what was in functional spec! Business requirements werent clear! BA missed it in the technical requirements! Dev BA Architect
  • We Found a Bug! How did QA miss this? That was obvious! I shouldnt Developers dont test before have to spell out every they throw it over the wall! detail! Exec TesterProductManager We did what was in functional spec! Business requirements werent clear! BA missed it in the technical requirements! Dev BA Architect
  • We Found a Bug! How did QA miss this? That was obvious! I shouldnt Developers dont test before have to spell out every they throw it over the wall! detail! Exec TesterProductManager We did what was in functional spec! Business requirements werent clear! BA missed it in the technical requirements! Dev BA Architect
  • Accidental Adversaries + Testing + New Bugs - + - +Testing Additional Development Software FixSuccess Tests Success + -+ - New Build + Development +
  • Functional SilosSource: http://www.danpontefract.com/images/silo.jpg
  • Build it Right Build the Right ThingSpecification By ExampleGojko Adzic, 2011 page 4
  • Build it Right Build the Right Thing Useless CrapSpecification By ExampleGojko Adzic, 2011 page 4
  • Build it Right Business Failure Build the Right Thing Useless CrapSpecification By ExampleGojko Adzic, 2011 page 4
  • Build it Right Business Failure Build the Right Thing Useless Crap Maintenance NightmareSpecification By ExampleGojko Adzic, 2011 page 4
  • Build it Right Business Failure Business Success Build the Right Thing Useless Crap Maintenance NightmareSpecification By ExampleGojko Adzic, 2011 page 4
  • Build it Right Business Failure Business Success Specification By Example Build the Right Thing Useless Crap Maintenance NightmareSpecification By ExampleGojko Adzic, 2011 page 4
  • What are Specifications By Example?
  • What are Specifications By Example?• Thin slices of system behaviour• that deliver business value• described as concrete examples• that are potentially automatable• without translation• to create executable specifications• captured in live documentation.
  • Agile Testing Quadrants
  • Specification By Example
  • Specification By Example Business Goal
  • Specification By Example Business Goal Derive the scope Scope
  • Specification By Example Business Goal Derive the scope Scope Specify collaboratively Key Examples
  • Specification By Example Business Goal Derive the scope Scope Specify collaboratively Key Examples Refine the specification Specification With Examples
  • Specification By Example Business Goal Derive the scope Scope Specify collaboratively Key Examples Refine the specification Specification With Examples Automate literally Executable Specification
  • Specification By Example Business Goal Derive the scope Scope Specify collaboratively Key Examples Refine the specification Specification With Examples Automate literally Executable Specification Validate frequently Living Documentation
  • Specification By Example Business Goal Derive the scope Scope Shared Understanding Ubiquitous Language Specify collaboratively Key Examples Refine the specification Specification With Examples Automate literally Executable Specification Validate frequently Living Documentation
  • Source: https://docs.google.com/drawings/d/1cbfKq-KazcbMVCnRfih6zMSDBdtf90KviV7l2oxGyWM/edit Specification By Example Business Goal Derive the scope Scope Shared Understanding Ubiquitous Language Specify collaboratively Key Examples Refine the specification Specification With Examples Automate literally Executable Specification Validate frequently Living Documentation
  • Derive the Scope: Story MappingSource: http://availagility.co.uk/wp-content/uploads/2008/10/user-story-mapping.png
  • Derive the Scope: User Stories
  • Derive the Scope: User Stories As a _______ I want to _______ So that _______
  • Derive the Scope: User Stories As a _______ I want to _______ So that _______ As a student I want to purchase used books online So that I can save money
  • Specify Collaboratively: Workshops
  • Specify Collaboratively: Workshops
  • Specify Collaboratively: Workshops • Hold regular product backlog workshops
  • Specify Collaboratively: Workshops • Hold regular product backlog workshops • Full team workshops - when starting
  • Specify Collaboratively: Workshops • Hold regular product backlog workshops • Full team workshops - when starting • Three amigo workshops: • One developer • One tester • One analyst
  • Specify Collaboratively: Key Examples
  • Specify Collaboratively: Key Examples Given _______ When _______ Then _______
  • Specify Collaboratively: Key Examples Given _______ When _______ Then _______Given “War and Peace” is available as a used book for $2.99 When Susan selects book“War and Peace” Then “Buy used for $2.99” is displayed
  • Refining the Specification
  • Refining the Specification“Specifications with examples are acceptance tests” Gojko Adzic
  • Refining the Specification“Specifications with examples are acceptance tests” Gojko Adzic• Be precise and make sure spec is testable
  • Refining the Specification“Specifications with examples are acceptance tests” Gojko Adzic• Be precise and make sure spec is testable• Avoid “scripts” and “flows”
  • Refining the Specification“Specifications with examples are acceptance tests” Gojko Adzic• Be precise and make sure spec is testable• Avoid “scripts” and “flows”• Focus on business functionality not design
  • Refining the Specification“Specifications with examples are acceptance tests” Gojko Adzic• Be precise and make sure spec is testable• Avoid “scripts” and “flows”• Focus on business functionality not design• Avoid UI details
  • Refining the Specification“Specifications with examples are acceptance tests” Gojko Adzic• Be precise and make sure spec is testable• Avoid “scripts” and “flows”• Focus on business functionality not design• Avoid UI details• Avoid covering every possible combination
  • Refining the Specification: An Example Free Delivery Free delivery is offered to VIP customers once they purchase a certain number of books. Free delivery is not offered to regular customers or VIP customers buying anything other than books. Customer Type Cart Contents Delivery VIP 5 books Free, Standard VIP 4 books Standard Regular 10 books Standard VIP 5 dishwashers Standard VIP 5 books, 1 dishwasher StandardSource: Specification by Example: How successful teams deliver the right software, Gojko Adzic, pg. 116
  • Automating Examples
  • Automating Examples• Start small
  • Automating Examples• Start small• Select important examples for automation
  • Automating Examples• Start small• Select important examples for automation• Plan up-front to automate
  • Automating Examples• Start small• Select important examples for automation• Plan up-front to automate• Be prepared to go slower at the start
  • Automating Examples• Start small• Select important examples for automation• Plan up-front to automate• Be prepared to go slower at the start• Treat automation code as a first class citizen
  • Automating Examples• Start small• Select important examples for automation• Plan up-front to automate• Be prepared to go slower at the start• Treat automation code as a first class citizen• Avoid record and playback
  • Automating Examples• Start small• Select important examples for automation• Plan up-front to automate• Be prepared to go slower at the start• Treat automation code as a first class citizen• Avoid record and playback• Avoid using pre-populated data
  • Minimize Tests Through the UI build trust via UI tests automate below the UI
  • Automation ToolsFitNesse Cucumber ConcordianGreen JBehave TwistPepper RobotText Test SpecFlow Framework
  • Validate Frequently
  • Validate Frequently• Start with a Continuous Integration system
  • Validate Frequently• Start with a Continuous Integration system• Set up a Continuous Deployment system
  • Validate Frequently• Start with a Continuous Integration system• Set up a Continuous Deployment system• Specify and test business logic separately from end-to-end flows
  • Validate Frequently• Start with a Continuous Integration system• Set up a Continuous Deployment system• Specify and test business logic separately from end-to-end flows• Organize tests along functional lines
  • Validate Frequently• Start with a Continuous Integration system• Set up a Continuous Deployment system• Specify and test business logic separately from end-to-end flows• Organize tests along functional lines• Run all test nightly
  • Validate Frequently• Start with a Continuous Integration system• Set up a Continuous Deployment system• Specify and test business logic separately from end-to-end flows• Organize tests along functional lines• Run all test nightly• Consider an iteration “test pack”
  • Living Documentation• Keep specifications short• Evolve a specification language and leverage in with “common fixtures”• Make documentation accessible - consider a wiki• Organize the documentation• Put specifications under version control
  • A Worked Example
  • Executable Specification
  • Cucumber Organization fixtures are common Features Step System
  • Cucumber Organization fixtures are common ad Lo Features Step System
  • Cucumber Organization fixtures are common M ad at Lo ch Features Step System
  • Cucumber Organization fixtures are common M ad at Lo ch Features Step Call System
  • Feature File Feature: Turn cucumber into beer As a cucumber presenter I want beer after my presentation So I can enjoy the rest of DemoCampGuelph Scenario: Brydon buys Declan beer Given Brydon hosts DemoCampGuelph When Declan demos Cucumber Then Brydon should buy Declan 1 beer Scenario: Ali buys Declan beer Given Ali hosts DemoCampGuelph When Declan demos Cucumber Then Ali should buy Declan 1 beer
  • Step DefinitionsGiven /^(.+) hosts/ do |host| @event = Event.new(host)endWhen /^(.+) demos/ do |presenter| @event.add(presenter)endThen /^(.+) should buy (.+) (d+) (.*)$/ do |buyer, drinker,qty, item| perk = @event.perks[0]; perk.buyer.should == buyer; perk.receiver.should ==drinker perk.quantity.should == quantity.to_i; perk.item.should== itemend
  • System Under Test class Event attr_reader :perks def initialize(host) @host = host; @perks = [] end def add(presenter) @perks.push Perk.new(@host, presenter, 1, "beer") end end class Perk attr_reader :buyer, :receiver, :quantity, :item def initialize(buyer, receiver, quantity, item) @buyer = buyer; @receiver = receiver @quantity = quantity; @item = item end end
  • ExecutionScenario: Brydon buys Declan beer Given Brydon hosts DemoCampGuelph When Declan demos Cucumber Then Brydon should buy Declan 1 beer
  • ExecutionScenario: Brydon buys Declan beer Given Brydon hosts DemoCampGuelph When Declan demos Cucumber Then Brydon should buy Declan 1 beerGiven /^(.+) hosts/ do | When /^(.+) demos/ do |host| presenter| @event = @event.add(presenter)Event.new(host) endEndThen /^(.+) should buy (.+) (d+) (.*)$/ do |buyer,drinker, qty, item| perk = @event.perks[0]; perk.buyer.should == buyer; perk.receiver.should ==drinker
  • ExecutionScenario: Brydon buys Declan beer Given Brydon hosts DemoCampGuelph When Declan demos Cucumber Then Brydon should buy Declan 1 beerGiven /^(.+) hosts/ do |host| @event =Event.new(host)End
  • ExecutionScenario: Brydon buys Declan beer Given Brydon hosts DemoCampGuelph When Declan demos Cucumber Then Brydon should buy Declan 1 beerGiven /^(.+) hosts/ do |host| “Brydon” @event =Event.new(host)End
  • ExecutionScenario: Brydon buys Declan beer Given Brydon hosts DemoCampGuelph When Declan demos Cucumber Then Brydon should buy Declan 1 beer
  • ExecutionScenario: Brydon buys Declan beer Given Brydon hosts DemoCampGuelph When Declan demos Cucumber Then Brydon should buy Declan 1 beerGiven /^(.+) hosts/ do | When /^(.+) demos/ do |host| presenter| @event = @event.add(presenter)Event.new(host) endEndThen /^(.+) should buy (.+) (d+) (.*)$/ do |buyer,drinker, qty, item| perk = @event.perks[0]; perk.buyer.should == buyer; perk.receiver.should ==drinker
  • ExecutionScenario: Brydon buys Declan beer Given Brydon hosts DemoCampGuelph When Declan demos Cucumber Then Brydon should buy Declan 1 beer When /^(.+) demos/ do | presenter| @event.add(presenter) end
  • ExecutionScenario: Brydon buys Declan beer Given Brydon hosts DemoCampGuelph When Declan demos Cucumber Then Brydon should buy Declan 1 beer When /^(.+) demos/ do | presenter| @event.add(presenter) end “Declan”
  • ExecutionScenario: Brydon buys Declan beer Given Brydon hosts DemoCampGuelph When Declan demos Cucumber Then Brydon should buy Declan 1 beer
  • ExecutionScenario: Brydon buys Declan beer Given Brydon hosts DemoCampGuelph When Declan demos Cucumber Then Brydon should buy Declan 1 beerGiven /^(.+) hosts/ do | When /^(.+) demos/ do |host| presenter| @event = @event.add(presenter)Event.new(host) endEndThen /^(.+) should buy (.+) (d+) (.*)$/ do |buyer,drinker, qty, item| perk = @event.perks[0]; perk.buyer.should == buyer; perk.receiver.should ==drinker
  • ExecutionScenario: Brydon buys Declan beer Given Brydon hosts DemoCampGuelph When Declan demos Cucumber Then Brydon should buy Declan 1 beerThen /^(.+) should buy (.+) (d+) (.*)$/ do |buyer,drinker, qty, item| perk = @event.perks[0]; perk.buyer.should == buyer; perk.receiver.should ==drinker
  • ExecutionScenario: Brydon buys Declan beer Given Brydon hosts DemoCampGuelph When Declan demos Cucumber Then Brydon should buy Declan 1 beerThen /^(.+) should buy (.+) (d+) (.*)$/ do |buyer,drinker, qty, item| perk = @event.perks[0]; perk.buyer.should == buyer; perk.receiver.should ==drinker
  • Specification By Example
  • Specification By Example Business Goal
  • Specification By Example Business Goal Derive the scope Scope
  • Specification By Example Business Goal Derive the scope Scope Specify collaboratively Key Examples
  • Specification By Example Business Goal Derive the scope Scope Specify collaboratively Key Examples Refine the specification Specification With Examples
  • Specification By Example Business Goal Derive the scope Scope Specify collaboratively Key Examples Refine the specification Specification With Examples Automate literally Executable Specification
  • Specification By Example Business Goal Derive the scope Scope Specify collaboratively Key Examples Refine the specification Specification With Examples Automate literally Executable Specification Validate frequently Living Documentation
  • Specification By Example Business Goal Derive the scope Scope Shared Understanding Ubiquitous Language Specify collaboratively Key Examples Refine the specification Specification With Examples Automate literally Executable Specification Validate frequently Living Documentation
  • Source: https://docs.google.com/drawings/d/1cbfKq-KazcbMVCnRfih6zMSDBdtf90KviV7l2oxGyWM/edit Specification By Example Business Goal Derive the scope Scope Shared Understanding Ubiquitous Language Specify collaboratively Key Examples Refine the specification Specification With Examples Automate literally Executable Specification Validate frequently Living Documentation
  • WaterfallSource: http://www.cs.umd.edu/class/spring2003/cmsc838p/Process/waterfall.pdf
  • Waterfall XSource: http://www.cs.umd.edu/class/spring2003/cmsc838p/Process/waterfall.pdf
  • Agile Specification Agile&Approach& Itera/on&1& Itera/on&2& Itera/on&3& Itera/on&4& Requirements& Requirements& Requirements& Requirements& Analysis&&&Design& Analysis&&&Design& Analysis&&&Design& Analysis&&&Design& Cost% of% Code& Code& Code& Code&Change% Test& Test& Test& Test& Deploy& Time%
  • Functional SilosSource: http://www.danpontefract.com/images/silo.jpg
  • Functional Silos XSource: http://www.danpontefract.com/images/silo.jpg
  • Collaborative Specification
  • Build it Right Build the Right ThingSpecification By ExampleGojko Adzic, 2011 page 4
  • Build it Right Build the Right Thing Useless CrapSpecification By ExampleGojko Adzic, 2011 page 4
  • Build it Right Business Failure Build the Right Thing Useless CrapSpecification By ExampleGojko Adzic, 2011 page 4
  • Build it Right Business Failure Build the Right Thing Useless Crap Maintenance NightmareSpecification By ExampleGojko Adzic, 2011 page 4
  • Build it Right Business Failure Business Success Build the Right Thing Useless Crap Maintenance NightmareSpecification By ExampleGojko Adzic, 2011 page 4
  • Build it Right Business Failure Business Success Specification By Example Build the Right Thing Useless Crap Maintenance NightmareSpecification By ExampleGojko Adzic, 2011 page 4
  • ReadingSpecification By ExampleGojko AdzicThe RSpec Book: Behaviour Driven Development withRSpec, Cucumber and FriendsDavid Cheliminksy et alAgile Testing: A Practical Guide for Testers and Agile TeamsLisa Crispin, Janet Gregory
  • Diagram Credits Lisa Crispin and Janet Gregory Agile Testing: A Practical Guide for Testers and Agile Teams Addison-Wesley Professional; January 9, 2009. Mike Cohn Succeeding with Agile: Software Development Using Scrum Addison-Wesley Professional; November 5, 2009.