Cucumbered

67
Cucumbered Joseph Wilk customers discussion collaboration acceptance language value

description

Presentation on Cucumber given at FutureRuby

Transcript of Cucumbered

Page 1: Cucumbered

Cucumbered

Joseph Wilk

customersdiscussioncollaboration

acceptance

languagevalue

Page 2: Cucumbered

Why are you here?

Page 3: Cucumbered

Why are you here?In order ...

Page 4: Cucumbered

Why are you here?In order ...As a FutureRuby attendee

Page 5: Cucumbered

Why are you here?In order ...As a FutureRuby attendeeI want ...

Page 6: Cucumbered

Why are you here?In order ...As a FutureRuby attendeeI want ...

I’ll show you a good time

Page 7: Cucumbered

What’s your acceptance criteria?

Page 8: Cucumbered

Scenario: Ecstatic FutureRuby attendees Given people turned up When Joseph talks Then everyone should learn something new And no-one should fall asleep And no cucumbers should be thrown

Page 9: Cucumbered

Fail

Pass

Page 10: Cucumbered

Fail

Pass

Page 11: Cucumbered

Outside-in

interface

Users

Page 12: Cucumbered

“I believe that the hardest part of software projects, the most common source of project failure, is communication with the customers and users of that software.

By providing a clear yet precise language to deal with domains, a DSL can help improve this communication.”

Martin Fowler

Page 13: Cucumbered

def given_ruby_provides_a_great_dsl(*arg) developers.should be_happyend

given_ruby_provides_a_great_dsl 'run away!'

Page 14: Cucumbered

def given_ruby_provides_a_great_dsl(*arg) developers.should be_happyend

given_ruby_provides_a_great_dsl 'run away!'

Developer

Page 15: Cucumbered

Why do I quote things?

Underscores!Why can

I not use ‘ $

わかりません

Customer

Page 16: Cucumbered

Customer Developer

Tester

Page 17: Cucumbered

Customer Developer

Tester

Cucumber

Page 18: Cucumbered

RubyPlaintext

Customer Developer

Tester

Page 19: Cucumbered

For Cuke Sake Why?

• Token Conversation• Acceptance Criteria

• Design• Documentation

• Functional test• Integration test

Page 20: Cucumbered

Cucumber FeatureFeature: Be awesome NarrativeScenario: title which rocks Given <some context> And <yet more context> When <some action> And <more actions> Then <some outcome> And <more outcomes>

Not executedExample of

behaviour

Steps

Page 21: Cucumbered

Plaintext

RubyRuby

Page 22: Cucumbered

Plaintext

Ruby

Given we like cukes

Ruby

Step

Page 23: Cucumbered

Plaintext

Ruby

Given /^we like (.*)$/i do |fruit| fruit.should == 'cukes' #assert_equal(fruit, 'cukes')end

Given we like cukes

Ruby

Step

Stepdefinition

Page 24: Cucumbered

Plaintext

Ruby

Given /^we like (.*)$/i do |fruit| fruit.should == 'cukes' #assert_equal(fruit, 'cukes')end

regexp match

Given we like cukes

Ruby

Step

Stepdefinition

Page 25: Cucumbered

Cucumber provides the venue

Sinatra

RailsCuke4Duke

Page 26: Cucumbered

Cucumber Gateway?

Clojure

Cucumber

Java Virtual Machine

World domination?

Page 27: Cucumbered

Cucumber English

Page 28: Cucumbered

Cucumber English

Page 29: Cucumbered

огурец Russianconcombre Frenchキュウリ JapaneseOkurkový CzechGurke GermanCucumber Englishpepino Spanishcetriolo Italianagurk Danishاخليار Arabicketimun Indonesianמְלָפְפֹון HebrewCogombre CatalanCUCUMBR LOLCatsAgurk Norwegian

Page 30: Cucumbered

огурец Russianconcombre Frenchキュウリ JapaneseOkurkový CzechGurke GermanCucumber Englishpepino Spanishcetriolo Italianagurk Danishاخليار Arabicketimun Indonesianמְלָפְפֹון HebrewCogombre CatalanCUCUMBR LOLCatsAgurk Norwegian

黄瓜 Chinese

오이 Korean

gurka Swedish

castravete Romanian

ogórek Polish

Kurk Estonian

dưa chuột Vietnamese

uhorka Slovak

gurķis Latvian

Agurkas Lithuanian

Salátauborka Hungarian

Kurkku Finnish

Краставица Bulgarian

Pepino Portuguese

Page 31: Cucumbered

# language: en-lolOH HAI: STUFFING

MISHUN: CUCUMBR I CAN HAZ IN TEH BEGINNIN 3 CUCUMBRZ WEN I EAT 2 CUCUMBRZ DEN I HAS 2 CUCUMBERZ IN MAH BELLY AN IN TEH END 1 CUCUMBRZ KTHXBAI

ICANHAZ /^IN TEH BEGINNIN (\d+) CUCUMBRZ$/ do |n| @basket = Basket.new(n.to_i)end

WEN /^I EAT (\d+) CUCUMBRZ$/ do |n| @belly = Belly.new @belly.eat(@basket.take(n.to_i))end

DEN /^I HAS (\d+) CUCUMBERZ IN MAH BELLY$/ do |n| @belly.cukes.should == n.to_iend

Page 32: Cucumbered

How Cucumber supports 28+ languages

Page 33: Cucumbered

How Cucumber supports 28+ languages

grammar Feature ...end

Page 34: Cucumbered

How Cucumber supports 28+ languages

grammar Feature ...end

compiled

Ruby

Page 35: Cucumbered

How Cucumber supports 28+ languages

grammar <%= keywords('grammar_name', true) %> rule step_keyword (<%= keywords('given') %>) / (<%= keywords('when') %>) / (<%= keywords('then') %>) / (<%= keywords('and') %>) / (<%= keywords('but') %>) end ...end

grammar Feature ...end

compiled

Ruby

Page 36: Cucumbered

"en-lol": name: LOLCAT native: LOLCAT encoding: UTF-8 feature: OH HAI background: B4 scenario: MISHUN scenario_outline: MISHUN SRSLY examples: EXAMPLZ given: I CAN HAZ when: WEN then: DEN and: AN but: BUT space_after_keyword: true

"en-au": name: Australian native: Australian encoding: UTF-8 feature: Crikey background: Background scenario: Mate scenario_outline: Blokes examples: Cobber given: Ya know how when: When then: Ya gotta and: N but: Cept space_after_keyword: true

Page 37: Cucumbered

Once more unto the breach,

dear friends

brace yourself

Page 38: Cucumbered

§

Page 39: Cucumbered

Feature Request

I want members to be able to rent a movie with a priority indicating how much they want to see the film

Page 40: Cucumbered

Token for Conversation

Talk to me

Page 41: Cucumbered

Feature: Film Member selects a movie to rent with priority In order to maximise allocation of films The Film member Needs to add movies to their rental list with a priority

Feature Injection

Page 42: Cucumbered

Feature: Film Member selects a movie to rent with priority In order to maximise allocation of films The Film member Needs to add movies to their rental list with a priority

Feature Injection

Value

Page 43: Cucumbered

Feature: Film Member selects a movie to rent with priority In order to maximise allocation of films The Film member Needs to add movies to their rental list with a priority

Feature Injection

Value

Role

Page 44: Cucumbered

Feature: Film Member selects a movie to rent with priority In order to maximise allocation of films The Film member Needs to add movies to their rental list with a priority

Feature Injection

Feature

Value

Role

Page 45: Cucumbered

AcceptanceDefinition of Done.

Are we done yet?

Page 46: Cucumbered

ScenariosFeature: Film Member selects a movie to rent with priority In order to maximise allocation of films The Film member Needs to add movies to their rental list with a priority Scenario: High priority

Page 47: Cucumbered

ScenariosFeature: Film Member selects a movie to rent with priority In order to maximise allocation of films The Film member Needs to add movies to their rental list with a priority Scenario: High priority Given I'm logged in When I touch the movie "Casshern" And I touch the "Rent High priority" button Then I should see "Movie added to rental list" And I should see "Casshern" in my rental list And "Casshern" should be marked as "High priority"

Page 48: Cucumbered

http://iphonemockup.lkmc.ch

Page 49: Cucumbered

Cuking time

About cuking time!

Page 50: Cucumbered

Low Res: http://www.vimeo.com/5642761

High Res: http://www.screencast.com/t/cZZ2cofHupn

Page 51: Cucumbered

Here’s one I Cuked earlier

Tasty

Page 52: Cucumbered

Low Res: http://www.vimeo.com/5642687

High Res: http://www.screencast.com/t/4JV2VQGMj2G

Page 53: Cucumbered

Getting Customersusing Cucumber

I don’t bite

Page 54: Cucumbered

Getting Customersusing Cucumber

I don’t bite

Page 55: Cucumbered

The Art of War Plaintext

, , @"===, ,_____cctI "?AAAAAAAAAAAAAAAA,,,,,,,,,,,,,,,,,,,,,;LLLLLLLLLL ~",,, 1""""""""""""###OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO '"EEEEE, !'"***"~~~~~~"OOOIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII ,EEEEE)>"'''???????"WWW!MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM "E.,)+="WWW~~~~~~#"OOO1OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO ,~:#")LLL!"+++???????"$$$1==========##/ &LLLLLLLLL;;;;;;;;;;;;,,,/ 1#LLLLLLLLLLLLLLLLLLLLLL! ,!###LLLLLL"'EEEE,'"LLLLL! !######LLL" "EEE" "LLLL" !#########L! "EEJ. "LL! !##########1 "JJ*,l" !############"! ,l" 1##########" 1"~~,~~" !##########" !###########! !###########1 !############! 1############# !"#############" !##############! 1##########"' A magnum, By calendron 1#####"' """""

Page 56: Cucumbered

Don’t force structure

Feature: Title In order to <value> As a <role> I want <feature>

Page 57: Cucumbered

Avoid Noise! Given I am able to loginGiven I am able to login

Page 58: Cucumbered

Avoid Inconsistency

Given I loginGiven I authenticateGiven I gain access

Page 59: Cucumbered

BalanceAbstraction

Given I go to the login pageAnd I fill in "username" with "cuke"And I fill in "password" with "cuker"And I click "login"

Given I'm logged in

Page 60: Cucumbered

Use Language Building blocks

Given /I’m logged in/ do User.create!(:user => 'josephwilk', :password => "pass") Given 'I fill in "password" with "josephwilk"' Given 'I fill in "password" with "pass"' Given 'I click "login"'end

Page 61: Cucumbered

Eye

TeethFoamDribble

Tagging

Head

Page 62: Cucumbered

TaggingFeature: Verify billing

@done Scenario: Missing product description

@in-progress Scenario: Several products

$ cucumber --tags ~@in-progress

$ cucumber --tags @done

Page 63: Cucumbered

Focused TestingRun just enough tests

@teleportFeature: Invent teleportation

@moneyFeature: Make lots of money

Page 64: Cucumbered

Continuous Integration(WIP)Work in progress Done

list movies

add movies

edit movies

delete movies

Pending PassFail

$ cucumber --wip --tags @WIP features/

Page 65: Cucumbered

Limiting Tags in FlowWork in progress Done

add movies

add movies

add movies

add movies

add movies

add movies

add movies

editmovies

add movies

add movies

add movies

deletemovies

$ cucumber --tags @WIP:3 features/