12. Acceptance
Given I am on the signup page
And I have filled in the form
When I click “sign up”
Then I should get email confirm.
Given...
When...
Then...
13. Acceptance
They are examples!
Given I am on the signup page
And I have filled in the form
When I click “sign up”
Then I should get email confirm.
Given...
When...
Then...
30. # language: en
Feature: Division
In order to avoid silly mistakes
Cashiers must be able to calculate a fraction
Scenario: Regular numbers
Given I have entered 3 into the calculator
And I have entered 2 into the calculator
When I press divide
Then the result should be 1.5 on the screen
32. OH HAI: STUFFING
MISHUN: CUCUMBR
I CAN HAZ IN TEH BEGINNIN "3" CUCUMBRZ
WEN I EAT "2" CUCUMBRZ
DEN I HAZ "2" CUCUMBERZ IN MAH BELLY
AN IN TEH END "1" CUCUMBRZ KTHXBAI!
33. # language: no
Egenskap: Summering
For å slippe å gjøre dumme feil
Som en regnskapsfører
Vil jeg kunne legge sammen
Scenario: to tall
Gitt at jeg har tastet inn 5
Og at jeg har tastet inn 7
Når jeg summerer
Så skal resultatet være 12
34. magyar
български Bahasa Indonesia
català italiano
Cymraeg lietuvių kalba русский
Česky latviešu Svenska
dansk Nederlands Slovensky
Deutsch norsk Узбекча
English polski Tiếng Việt
Australian português
LOLCAT română
Texan suomi
español français עברית
eesti keel hrvatski ﺍﻟﻌﺮﺑﻴﺔ
36. $ cucumber features/division.feature
# language: en
Feature: Division
In order to avoid silly mistakes
Cashiers must be able to calculate a fraction
Scenario: Regular numbers # features/division.feature:6
Given I have entered 3 into the calculator # features/division.feature:7
And I have entered 2 into the calculator # features/division.feature:8
When I press divide # features/division.feature:9
Then the result should be 1.5 on the screen # features/division.feature:10
1 scenario (1 undefined)
4 steps (4 undefined)
0m0.005s
37. You can implement step definitions for undefined steps with these snippets:
Given /^I have entered 3 into the calculator$/ do
pending
end
Given /^I have entered 2 into the calculator$/ do
pending
end
When /^I press divide$/ do
pending
end
Then /^the result should be 1.5 on the screen$/ do
pending
end
If you want snippets in a different programming language, just make sure a file
with the appropriate file extension exists where cucumber looks for step
definitions.
39. Given /I have entered (d+) into the calculator/ do |n|
@calc.push n.to_i
end
When /I press (w+)/ do |op|
@result = @calc.send op
end
Then /the result should be (.*) on the screen/ do |result|
@result.should == result.to_f
end
40. features
division.feature
step_definitions
calculator_steps.rb
lib
calculator.rb
41. $ cucumber features/division.feature
# language: en
Feature: Division
In order to avoid silly mistakes
Cashiers must be able to calculate a fraction
Scenario: Regular numbers # features/division.feature:6
Given I have entered 3 into the calculator # features/step_definitons/calculator_steps.rb:14
And I have entered 2 into the calculator # features/step_definitons/calculator_steps.rb:14
When I press divide # features/step_definitons/calculator_steps.rb:18
Then the result should be 1.5 on the screen # features/step_definitons/calculator_steps.rb:22
1 scenario (1 passed)
4 steps (4 passed)
0m0.005s
42. Steps & Step
Given the secret code is "r g y c"
@Given("^the secret code is "([^"]*)"$")
public void theSecretCodeIs(String code) {
game = new Game(code);
}
43. Scenario Outline
Scenario Outline: submit guess
Given the secret code is "<code>"
When I guess "<guess>"
Then the mark should be "<mark>"
Examples:
| code | guess | mark |
| r g y c | r g y c | bbbb |
| r g y c | r g c y | bbww |
| r g y c | y r g c | bwww |
| r g y c | c r g y | wwww |
44. Multiline args (String)
Then aslak.hellesoy@gmail.com should get email
"""
Hi aslak.hellesoy@gmail.com
Congratulations, Cucumberer was accepted.
See you at JavaZone!
"""
@Then("^(.*) should get email$")
public void email(String email, String body) {
}
45. Multiline args (Tables)
Given the following proposals
| email | title |
| aslak.hellesoy@gmail.com | Cucumber |
| bryan@brynary.com | Webrat |
@Given("^the following proposals$")
public void proposals(cuke4duke.Table proposals) {
}
46. Background
Feature: Notification emails
Background:
Given the following proposals exist
| email | title |
| aslak.hellesoy@gmail.com | Cucumber |
| bryan@brynary.com | Webrat |
Scenario: Approve all
Scenario: Reject Webrat
47. Tags
Feature: Take over the world
I want it all
@spanish @french @english
Scenario: Take over Europe
@spanish @english
Scenario: Take over America
@english
Scenario: Take over Australia
48. Tags
cucumber -t spanish doit.feature
Feature: Take over the world
I want it all
@spanish @french @english
Scenario: Take over Europe
@spanish @english
Scenario: Take over America
@english
Scenario: Take over Australia
49. Tags
Feature: Take over the world
I want it all
@spanish @french @english
Scenario: Take over Europe
@spanish @english
Scenario: Take over America
@english
Scenario: Take over Australia
50. Tags
cucumber -t ~french doit.feature
Feature: Take over the world
I want it all
@spanish @french @english
Scenario: Take over Europe
@spanish @english
Scenario: Take over America
@english
Scenario: Take over Australia
51. Formatters
Pretty
Progress
Profile
HTML
JUnit
Rerun
Your Own
BEKK - Consulting
Agile 2002
Open Source 2001
Author of Cucumber
Free, open source BDD
Slides different (Dorothy) - will upload to Slideshare and tweet.
Cucumber based on BDD
Reframing of TDD - test before code
Requirements before code
Communication via examples
Automation
Getting the words right
Examples later
Never lose track of business value (WHY)
Verification all the time
Requirement
Use Case
How to test?
How to develop?
How to test?
How to develop?
How to test?
How to develop?
Lack of this:
Common reason for failure and delay
Unambiguous ones
Detailed requirement
This is also a test
Written before code
Automated
Translate to Cucumber test
Leading BDD tool
Dozens of clones
1 year old - mature
Mindblowing
Big ecosystem
By far the most popular BDD tool out there
Big ecosystem
By far the most popular BDD tool out there
Big ecosystem
By far the most popular BDD tool out there
Big ecosystem
By far the most popular BDD tool out there
Big ecosystem
By far the most popular BDD tool out there
Big ecosystem
By far the most popular BDD tool out there
Big ecosystem
By far the most popular BDD tool out there
Big ecosystem
By far the most popular BDD tool out there
Big ecosystem
By far the most popular BDD tool out there
Print this month
Written in Ruby
Ruby is 16 - can sleep with other languages
See all the JVM ones?
All the JVM language support
Language - you have seen a little
What the testers use
I will show you the language features
AND the flow of usage
Icon means Gherkin
Remember the user story?
(Different example)
English as native language?
Who has cats
Keywords are translated
38 languages
Reason it&#x2019;s popular
Samisk
Who has cats
Keywords are translated
38 languages
Reason it&#x2019;s popular
Samisk
Who has cats
Keywords are translated
38 languages
Reason it&#x2019;s popular
Samisk
Language - you have seen a little
Treetop
Ragel
Show the res of the language
Simple - for biz
At the root of your project
Run it
Scroll down
Past the code
Can be Java, Scala, Groovy, C# etc.
The programmers hook it up to the code.
Code doesn&#x2019;t exist yet.
We fix it
LEARN REGEXP
AS MANY AS YOU WANT
SAME NUMBER
GENERATED FOR YOU
Mastermind game
Python string
Exception to previous rule. Extra stepdef arg
Store in Hibernate?
Diff
Hashes
Raw
Transpose
Map cols and rows
JUnit handy for Hudson
Incredible what people tweet about #cucumber
(Not all of it related to the tool)
Salad and drinks
Some other things :-)