SlideShare a Scribd company logo
1 of 25
Download to read offline
Cucumber

ihower@handlino.com
about me
    •              (a.k.a ihower)
        http://ihower.idv.tw/blog/



•
             http://handlino.com
           http://registrano.com
Q:
 In order ...
 As a COSCUP 2009 attendee
 I want ...
Q:
 In order ... [business value]
 As a COSCUP 2009 attendee [role]
 I want ... [feature]
?
What’s your acceptance criteria?
Scenario:     COSCUP 2009

Given
When ihower
Then
And
“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
“


            (DSL)
    ”
        Martin Fowler
(DSL)

?
Cucumber




               Ruby
     Feature
Cucumber Feature
    Feature:




{
    Scenario:
     Given <            >
     And <          >
     When <     >
     And <      >
     Then <          >
     And <          >
Given




Given /^             (.*)$/ do |fruit|
    #.... your test code
    assert_equal(fruit, '      ')
end
             Ruby
Given




Given /^             (.*)$/ do |fruit|
    #.... your test code
    assert_equal(fruit, '      ')
end
             Ruby
Given



                      Regexp match

Given /^             (.*)$/ do |fruit|
    #.... your test code
    assert_equal(fruit, '      ')
end
             Ruby
Cucumber
• Ruby and Rails
• JRuby and Java
• IronRuby and .NET
• FunFX and Flex
• Web apps in any lanuages, with:
 • Watir, Selenium, Mechanize, Webrat
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
Feature
   :
  
  
  
 
     :
                        3
                        2
         divide
                  1.5
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
Web Integration Testing
Feature:

 Scenario:
  Given I am on the "1934356085" book page
  When I press "Add to Cart"
  Then I should see "Programming Ruby 1.9"
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
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
{
              1:
              2:          Ruby
Outside
              3:                 (fail)
              4.                            (pass)

     Inside   {    4-1.
                   4-2
                             Unit Test    (Fail)
                                            (Pass)
thank you.
http://cukes.info/

More Related Content

Similar to Cucumber: 小黃瓜驗收測試工具

Cucumber Ru09 Web
Cucumber Ru09 WebCucumber Ru09 Web
Cucumber Ru09 WebJoseph Wilk
 
Rocket Fuelled Cucumbers
Rocket Fuelled CucumbersRocket Fuelled Cucumbers
Rocket Fuelled CucumbersJoseph Wilk
 
Behaviour driven development present
Behaviour driven development presentBehaviour driven development present
Behaviour driven development presentRaul Panjiyar
 
Executable Requirements with Behaviour-Driven Development and Cucumber - Euro...
Executable Requirements with Behaviour-Driven Development and Cucumber - Euro...Executable Requirements with Behaviour-Driven Development and Cucumber - Euro...
Executable Requirements with Behaviour-Driven Development and Cucumber - Euro...Aslak Hellesøy
 
Welcome to Swift (CocoaCoder 6/12/14)
Welcome to Swift (CocoaCoder 6/12/14)Welcome to Swift (CocoaCoder 6/12/14)
Welcome to Swift (CocoaCoder 6/12/14)Carl Brown
 
Cleanliness is Next to Domain-Specificity
Cleanliness is Next to Domain-SpecificityCleanliness is Next to Domain-Specificity
Cleanliness is Next to Domain-SpecificityBen Scofield
 
Cleanliness is Next to Domain-Specificity
Cleanliness is Next to Domain-SpecificityCleanliness is Next to Domain-Specificity
Cleanliness is Next to Domain-SpecificityViget Labs
 
Ruby presentasjon på NTNU 22 april 2009
Ruby presentasjon på NTNU 22 april 2009Ruby presentasjon på NTNU 22 april 2009
Ruby presentasjon på NTNU 22 april 2009Aslak Hellesøy
 
Ruby presentasjon på NTNU 22 april 2009
Ruby presentasjon på NTNU 22 april 2009Ruby presentasjon på NTNU 22 april 2009
Ruby presentasjon på NTNU 22 april 2009Aslak Hellesøy
 
Ruby presentasjon på NTNU 22 april 2009
Ruby presentasjon på NTNU 22 april 2009Ruby presentasjon på NTNU 22 april 2009
Ruby presentasjon på NTNU 22 april 2009Aslak Hellesøy
 
Behaviour driven infrastructure
Behaviour driven infrastructureBehaviour driven infrastructure
Behaviour driven infrastructureLindsay Holmwood
 
TechDays - IronRuby
TechDays - IronRubyTechDays - IronRuby
TechDays - IronRubyBen Hall
 
Torquebox OSCON Java 2011
Torquebox OSCON Java 2011Torquebox OSCON Java 2011
Torquebox OSCON Java 2011tobiascrawley
 
Migrating To Ruby1.9
Migrating To Ruby1.9Migrating To Ruby1.9
Migrating To Ruby1.9tomaspavelka
 
The $path to knowledge: What little it take to unit-test Perl.
The $path to knowledge: What little it take to unit-test Perl.The $path to knowledge: What little it take to unit-test Perl.
The $path to knowledge: What little it take to unit-test Perl.Workhorse Computing
 
Desktop Applications Using HTML & JavaScript (and Python & Ruby
Desktop Applications Using HTML & JavaScript (and Python & RubyDesktop Applications Using HTML & JavaScript (and Python & Ruby
Desktop Applications Using HTML & JavaScript (and Python & RubyAxway Appcelerator
 

Similar to Cucumber: 小黃瓜驗收測試工具 (20)

Cucumbered
CucumberedCucumbered
Cucumbered
 
Cucumber Ru09 Web
Cucumber Ru09 WebCucumber Ru09 Web
Cucumber Ru09 Web
 
Cucumber testing
Cucumber testingCucumber testing
Cucumber testing
 
Cucumber & BDD
Cucumber & BDDCucumber & BDD
Cucumber & BDD
 
Rocket Fuelled Cucumbers
Rocket Fuelled CucumbersRocket Fuelled Cucumbers
Rocket Fuelled Cucumbers
 
Behaviour driven development present
Behaviour driven development presentBehaviour driven development present
Behaviour driven development present
 
Executable Requirements with Behaviour-Driven Development and Cucumber - Euro...
Executable Requirements with Behaviour-Driven Development and Cucumber - Euro...Executable Requirements with Behaviour-Driven Development and Cucumber - Euro...
Executable Requirements with Behaviour-Driven Development and Cucumber - Euro...
 
Welcome to Swift (CocoaCoder 6/12/14)
Welcome to Swift (CocoaCoder 6/12/14)Welcome to Swift (CocoaCoder 6/12/14)
Welcome to Swift (CocoaCoder 6/12/14)
 
Cleanliness is Next to Domain-Specificity
Cleanliness is Next to Domain-SpecificityCleanliness is Next to Domain-Specificity
Cleanliness is Next to Domain-Specificity
 
Cleanliness is Next to Domain-Specificity
Cleanliness is Next to Domain-SpecificityCleanliness is Next to Domain-Specificity
Cleanliness is Next to Domain-Specificity
 
Ruby presentasjon på NTNU 22 april 2009
Ruby presentasjon på NTNU 22 april 2009Ruby presentasjon på NTNU 22 april 2009
Ruby presentasjon på NTNU 22 april 2009
 
Ruby presentasjon på NTNU 22 april 2009
Ruby presentasjon på NTNU 22 april 2009Ruby presentasjon på NTNU 22 april 2009
Ruby presentasjon på NTNU 22 april 2009
 
Ruby presentasjon på NTNU 22 april 2009
Ruby presentasjon på NTNU 22 april 2009Ruby presentasjon på NTNU 22 april 2009
Ruby presentasjon på NTNU 22 april 2009
 
Behaviour driven infrastructure
Behaviour driven infrastructureBehaviour driven infrastructure
Behaviour driven infrastructure
 
TechDays - IronRuby
TechDays - IronRubyTechDays - IronRuby
TechDays - IronRuby
 
Torquebox OSCON Java 2011
Torquebox OSCON Java 2011Torquebox OSCON Java 2011
Torquebox OSCON Java 2011
 
Migrating To Ruby1.9
Migrating To Ruby1.9Migrating To Ruby1.9
Migrating To Ruby1.9
 
An introduction to Ruby
An introduction to RubyAn introduction to Ruby
An introduction to Ruby
 
The $path to knowledge: What little it take to unit-test Perl.
The $path to knowledge: What little it take to unit-test Perl.The $path to knowledge: What little it take to unit-test Perl.
The $path to knowledge: What little it take to unit-test Perl.
 
Desktop Applications Using HTML & JavaScript (and Python & Ruby
Desktop Applications Using HTML & JavaScript (and Python & RubyDesktop Applications Using HTML & JavaScript (and Python & Ruby
Desktop Applications Using HTML & JavaScript (and Python & Ruby
 

More from Wen-Tien Chang

⼤語⾔模型 LLM 應⽤開發入⾨
⼤語⾔模型 LLM 應⽤開發入⾨⼤語⾔模型 LLM 應⽤開發入⾨
⼤語⾔模型 LLM 應⽤開發入⾨Wen-Tien Chang
 
Ruby Rails 老司機帶飛
Ruby Rails 老司機帶飛Ruby Rails 老司機帶飛
Ruby Rails 老司機帶飛Wen-Tien Chang
 
A brief introduction to Machine Learning
A brief introduction to Machine LearningA brief introduction to Machine Learning
A brief introduction to Machine LearningWen-Tien Chang
 
淺談 Startup 公司的軟體開發流程 v2
淺談 Startup 公司的軟體開發流程 v2淺談 Startup 公司的軟體開發流程 v2
淺談 Startup 公司的軟體開發流程 v2Wen-Tien Chang
 
RSpec on Rails Tutorial
RSpec on Rails TutorialRSpec on Rails Tutorial
RSpec on Rails TutorialWen-Tien Chang
 
ALPHAhackathon: How to collaborate
ALPHAhackathon: How to collaborateALPHAhackathon: How to collaborate
ALPHAhackathon: How to collaborateWen-Tien Chang
 
Git 版本控制系統 -- 從微觀到宏觀
Git 版本控制系統 -- 從微觀到宏觀Git 版本控制系統 -- 從微觀到宏觀
Git 版本控制系統 -- 從微觀到宏觀Wen-Tien Chang
 
Exception Handling: Designing Robust Software in Ruby (with presentation note)
Exception Handling: Designing Robust Software in Ruby (with presentation note)Exception Handling: Designing Robust Software in Ruby (with presentation note)
Exception Handling: Designing Robust Software in Ruby (with presentation note)Wen-Tien Chang
 
Exception Handling: Designing Robust Software in Ruby
Exception Handling: Designing Robust Software in RubyException Handling: Designing Robust Software in Ruby
Exception Handling: Designing Robust Software in RubyWen-Tien Chang
 
從 Classes 到 Objects: 那些 OOP 教我的事
從 Classes 到 Objects: 那些 OOP 教我的事從 Classes 到 Objects: 那些 OOP 教我的事
從 Classes 到 Objects: 那些 OOP 教我的事Wen-Tien Chang
 
Yet another introduction to Git - from the bottom up
Yet another introduction to Git - from the bottom upYet another introduction to Git - from the bottom up
Yet another introduction to Git - from the bottom upWen-Tien Chang
 
A brief introduction to Vagrant – 原來 VirtualBox 可以這樣玩
A brief introduction to Vagrant – 原來 VirtualBox 可以這樣玩A brief introduction to Vagrant – 原來 VirtualBox 可以這樣玩
A brief introduction to Vagrant – 原來 VirtualBox 可以這樣玩Wen-Tien Chang
 
Ruby 程式語言綜覽簡介
Ruby 程式語言綜覽簡介Ruby 程式語言綜覽簡介
Ruby 程式語言綜覽簡介Wen-Tien Chang
 
A brief introduction to SPDY - 邁向 HTTP/2.0
A brief introduction to SPDY - 邁向 HTTP/2.0A brief introduction to SPDY - 邁向 HTTP/2.0
A brief introduction to SPDY - 邁向 HTTP/2.0Wen-Tien Chang
 
RubyConf Taiwan 2012 Opening & Closing
RubyConf Taiwan 2012 Opening & ClosingRubyConf Taiwan 2012 Opening & Closing
RubyConf Taiwan 2012 Opening & ClosingWen-Tien Chang
 
從 Scrum 到 Kanban: 為什麼 Scrum 不適合 Lean Startup
從 Scrum 到 Kanban: 為什麼 Scrum 不適合 Lean Startup從 Scrum 到 Kanban: 為什麼 Scrum 不適合 Lean Startup
從 Scrum 到 Kanban: 為什麼 Scrum 不適合 Lean StartupWen-Tien Chang
 
那些 Functional Programming 教我的事
那些 Functional Programming 教我的事那些 Functional Programming 教我的事
那些 Functional Programming 教我的事Wen-Tien Chang
 
RubyConf Taiwan 2011 Opening & Closing
RubyConf Taiwan 2011 Opening & ClosingRubyConf Taiwan 2011 Opening & Closing
RubyConf Taiwan 2011 Opening & ClosingWen-Tien Chang
 

More from Wen-Tien Chang (20)

⼤語⾔模型 LLM 應⽤開發入⾨
⼤語⾔模型 LLM 應⽤開發入⾨⼤語⾔模型 LLM 應⽤開發入⾨
⼤語⾔模型 LLM 應⽤開發入⾨
 
Ruby Rails 老司機帶飛
Ruby Rails 老司機帶飛Ruby Rails 老司機帶飛
Ruby Rails 老司機帶飛
 
A brief introduction to Machine Learning
A brief introduction to Machine LearningA brief introduction to Machine Learning
A brief introduction to Machine Learning
 
淺談 Startup 公司的軟體開發流程 v2
淺談 Startup 公司的軟體開發流程 v2淺談 Startup 公司的軟體開發流程 v2
淺談 Startup 公司的軟體開發流程 v2
 
RSpec on Rails Tutorial
RSpec on Rails TutorialRSpec on Rails Tutorial
RSpec on Rails Tutorial
 
RSpec & TDD Tutorial
RSpec & TDD TutorialRSpec & TDD Tutorial
RSpec & TDD Tutorial
 
ALPHAhackathon: How to collaborate
ALPHAhackathon: How to collaborateALPHAhackathon: How to collaborate
ALPHAhackathon: How to collaborate
 
Git 版本控制系統 -- 從微觀到宏觀
Git 版本控制系統 -- 從微觀到宏觀Git 版本控制系統 -- 從微觀到宏觀
Git 版本控制系統 -- 從微觀到宏觀
 
Exception Handling: Designing Robust Software in Ruby (with presentation note)
Exception Handling: Designing Robust Software in Ruby (with presentation note)Exception Handling: Designing Robust Software in Ruby (with presentation note)
Exception Handling: Designing Robust Software in Ruby (with presentation note)
 
Exception Handling: Designing Robust Software in Ruby
Exception Handling: Designing Robust Software in RubyException Handling: Designing Robust Software in Ruby
Exception Handling: Designing Robust Software in Ruby
 
從 Classes 到 Objects: 那些 OOP 教我的事
從 Classes 到 Objects: 那些 OOP 教我的事從 Classes 到 Objects: 那些 OOP 教我的事
從 Classes 到 Objects: 那些 OOP 教我的事
 
Yet another introduction to Git - from the bottom up
Yet another introduction to Git - from the bottom upYet another introduction to Git - from the bottom up
Yet another introduction to Git - from the bottom up
 
A brief introduction to Vagrant – 原來 VirtualBox 可以這樣玩
A brief introduction to Vagrant – 原來 VirtualBox 可以這樣玩A brief introduction to Vagrant – 原來 VirtualBox 可以這樣玩
A brief introduction to Vagrant – 原來 VirtualBox 可以這樣玩
 
Ruby 程式語言綜覽簡介
Ruby 程式語言綜覽簡介Ruby 程式語言綜覽簡介
Ruby 程式語言綜覽簡介
 
A brief introduction to SPDY - 邁向 HTTP/2.0
A brief introduction to SPDY - 邁向 HTTP/2.0A brief introduction to SPDY - 邁向 HTTP/2.0
A brief introduction to SPDY - 邁向 HTTP/2.0
 
RubyConf Taiwan 2012 Opening & Closing
RubyConf Taiwan 2012 Opening & ClosingRubyConf Taiwan 2012 Opening & Closing
RubyConf Taiwan 2012 Opening & Closing
 
從 Scrum 到 Kanban: 為什麼 Scrum 不適合 Lean Startup
從 Scrum 到 Kanban: 為什麼 Scrum 不適合 Lean Startup從 Scrum 到 Kanban: 為什麼 Scrum 不適合 Lean Startup
從 Scrum 到 Kanban: 為什麼 Scrum 不適合 Lean Startup
 
Git Tutorial 教學
Git Tutorial 教學Git Tutorial 教學
Git Tutorial 教學
 
那些 Functional Programming 教我的事
那些 Functional Programming 教我的事那些 Functional Programming 教我的事
那些 Functional Programming 教我的事
 
RubyConf Taiwan 2011 Opening & Closing
RubyConf Taiwan 2011 Opening & ClosingRubyConf Taiwan 2011 Opening & Closing
RubyConf Taiwan 2011 Opening & Closing
 

Cucumber: 小黃瓜驗收測試工具

  • 2. about me • (a.k.a ihower) http://ihower.idv.tw/blog/ • http://handlino.com http://registrano.com
  • 3. Q: In order ... As a COSCUP 2009 attendee I want ...
  • 4. Q: In order ... [business value] As a COSCUP 2009 attendee [role] I want ... [feature]
  • 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
  • 8. (DSL) ” Martin Fowler
  • 10. Cucumber Ruby Feature
  • 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
  • 17.
  • 18. Feature :               :      3      2      divide      1.5
  • 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)