6. Scenario: COSCUP 2009
Given
When ihower
Then
And
7. “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
11. Cucumber Feature
Feature:
{
Scenario:
Given < >
And < >
When < >
And < >
Then < >
And < >
12. Given
Given /^ (.*)$/ do |fruit|
#.... your test code
assert_equal(fruit, ' ')
end
Ruby
13. Given
Given /^ (.*)$/ do |fruit|
#.... your test code
assert_equal(fruit, ' ')
end
Ruby
14. Given
Regexp match
Given /^ (.*)$/ do |fruit|
#.... your test code
assert_equal(fruit, ' ')
end
Ruby
15. Cucumber
• Ruby and Rails
• JRuby and Java
• IronRuby and .NET
• FunFX and Flex
• Web apps in any lanuages, with:
• Watir, Selenium, Mechanize, Webrat
16. Cucumber огурец Russian
concombre French
Japanese
Okurkový Czech
Gurke German
Cucumber English
pepino Spanish
!! Korean
cetriolo Italian
gurka Swedish
agurk Danish
castravete Romanian
Arabic ﺍﳋﻴﺎﺭ
ogórek Polish
ketimun Indonesian
Kurk Estonian
Hebrew מְלָפְפֹון
dưa chuột Vietnamese
Cogombre Catalan
uhorka Slovak
CUCUMBR LOLCats
gurķis Latvian
Agurk Norwegian
Agurkas Lithuanian
黄 !! Korean
Salátauborka Hungarian
gurka Swedish
Kurkku Finnish
castravete Romanian
Краставица Bulgarian
ogórek Polish
Pepino Portuguese
Kurk Estonian
dưa chuột Vietnamese
uhorka Slovak
gurķis Latvian
Agurkas Lithuanian
Salátauborka Hungarian
Kurkku Finnish
Краставица Bulgarian
Pepino Portuguese
19. Ruby code
Given / (d+)/ do |n|
@calc.push n.to_i
end
When / (w+)/ do |op|
@result = @calc.send op
end
Then / (.*)/ do |result|
@result.should == result.to_f
end
21. Feature:
Scenario:
Given I am on the "1934356085" book page
When I press "Add to Cart"
Then I should see "Programming Ruby 1.9"
22. Ruby Code
Given /^I am on (.+)$/ do |page_name|
visit path_to(page_name)
end
When /^I press "([^"]*)"$/ do |button|
click_button(button)
end
Then /^I should see "([^"]*)"$/ do |text|
response.should contain(text)
end
23. Ruby Code
Given /^I am on (.+)$/ do |page_name|
visit path_to(page_name)
end
When /^I press "([^"]*)"$/ do |button|
click_button(button)
end
Then /^I should see "([^"]*)"$/ do |text|
response.should contain(text)
end
24. {
1:
2: Ruby
Outside
3: (fail)
4. (pass)
Inside { 4-1.
4-2
Unit Test (Fail)
(Pass)