SlideShare uma empresa Scribd logo
1 de 29
Baixar para ler offline
Integration Test
 with Cucumber and Webrat




     Kang-min Liu
   gugod@gugod.org
Integration Test

•
•
• Web App:
: twitter
: twitter

1.            http://twitter.com/home

2.     status

3.   update

4.
Webrat

visit "http://twitter.com/home"
fill_in "status", :with => "lorem ipsum"
click_button "update"

response.body.should =~ /lorem ipsum/
Webrat
Browser emulation / control
Webrat

•
•
•
•
Webrat


•   javascript

•   css
Webrat

•
    • Selenium
    • Watir
Webrat Core API
•   visit        •   select

•   click_link   •   attach_file

•   fill_in       •   click_button

•   check

•   uncheck

•   choose
Webrat Core API

• visit, click_link
 • get + assert_response :success
• click_button
 • submit form + assert_response :success
 • submit form default values if any
Webrat + RSpec
describe "tweeting" do
  it "should show my tweets" do
    visit "/home"
    fill_in "status", :with => "lorem ipsum"
    click_button "update"
    response.body.should =~ /lorem ipsum/
  end
end
?
Goods

•
•    HTML

•
Cucumber

• BDD (Behavior Driven Development) Tool
• Ruby implementation
•
•
Feature: Update my status
  In order to keep friends posted
  As a friendly person
  I post my status to twitter

  Scenario: Update my status
    Given I go to “/home”
    When I fill in “status” with “lorem ipsum”
    And I click “send”
    Then I should see “lorem ipsum”
Feature: Update my status
  In order to keep friends posted
  As a friendly person
  I post my status to twitter

  Scenario: Update my status
    Given I go to “/home”
    When I fill in “status” with “lorem ipsum”
    And I click “send”
    Then I should see “lorem ipsum”
Feature: Update my status
  In order to keep friends posted
  As a friendly person
  I post my status to twitter

  Scenario: Update my status
    Given I go to “/home”
    When I fill in “status” with “lorem ipsum”
    And I click “send”
    Then I should see “lorem ipsum”
Scenario: Update my status
   Given I go to “/home”
   When I fill in “status” with “lorem ipsum”
   And I click “send”
   Then I should see “lorem ipsum”

Given –
When –
Then –
Given /^I go to "(.*)"$/ do |url|
  visit url
end

When /^I fill in "(.*)" with "(.*)"$/ do |field,value|
  fill_in field, :with => value
end

When /^I click "(.*)"$/ do |link|
  click_link(link)
end

Then /^I should see "(.*)"$/ do |text|
  response.body.should =~ /#{text}/m
end
?
Goods...
•

•
    •
    •
Goods...


•
    •
Scenario: Update my status
  Given I go to “/home”
  When I fill in “status” with “lorem ipsum”
  And I click “send”
  Then I should see “lorem ipsum”
describe "tweeting" do
  it "should show my tweets" do
    visit "/home"
    fill_in "status", :with => "lorem ipsum"
    click_button "update"
    response.body.should =~ /lorem ipsum/
  end
end
Reference

• Cucumber http://cukes.info/
• Webrat http://github.com/brynary/webrat/
  tree/master
• Test::Cukes http://search.cpan.org/dist/Test-
  Cukes/ (Perl implementation)

Mais conteúdo relacionado

Mais procurados

Mais procurados (14)

Functional testing with capybara
Functional testing with capybaraFunctional testing with capybara
Functional testing with capybara
 
Rails 101
Rails 101Rails 101
Rails 101
 
Open Source Principles for Internal Engineering Teams
Open Source Principles for Internal Engineering TeamsOpen Source Principles for Internal Engineering Teams
Open Source Principles for Internal Engineering Teams
 
Professional Persona Project
Professional Persona ProjectProfessional Persona Project
Professional Persona Project
 
WordPress maintenance - Keeping it all running smoothly
WordPress maintenance - Keeping it all running smoothlyWordPress maintenance - Keeping it all running smoothly
WordPress maintenance - Keeping it all running smoothly
 
Fetch with Frankie and Bowser
Fetch with Frankie and BowserFetch with Frankie and Bowser
Fetch with Frankie and Bowser
 
From 0 to Ember
From 0 to EmberFrom 0 to Ember
From 0 to Ember
 
Merb Router
Merb RouterMerb Router
Merb Router
 
greach 2014 marco vermeulen bdd using cucumber jvm and groovy
greach 2014 marco vermeulen bdd using cucumber jvm and groovygreach 2014 marco vermeulen bdd using cucumber jvm and groovy
greach 2014 marco vermeulen bdd using cucumber jvm and groovy
 
Mixing Objective-C, Swift and Japan
Mixing Objective-C, Swift and JapanMixing Objective-C, Swift and Japan
Mixing Objective-C, Swift and Japan
 
Popular SEO plugin for WordPress - WordCamp Pune 2015
Popular SEO plugin for WordPress - WordCamp Pune 2015Popular SEO plugin for WordPress - WordCamp Pune 2015
Popular SEO plugin for WordPress - WordCamp Pune 2015
 
Cucumber Ru09 Web
Cucumber Ru09 WebCucumber Ru09 Web
Cucumber Ru09 Web
 
Drupal8 Front-end Automated Testing
Drupal8 Front-end Automated TestingDrupal8 Front-end Automated Testing
Drupal8 Front-end Automated Testing
 
Tornado
TornadoTornado
Tornado
 

Semelhante a Integration Test With Cucumber And Webrat

Behavior Driven Development with Cucumber
Behavior Driven Development with CucumberBehavior Driven Development with Cucumber
Behavior Driven Development with Cucumber
Brandon Keepers
 

Semelhante a Integration Test With Cucumber And Webrat (20)

Selenium再入門
Selenium再入門Selenium再入門
Selenium再入門
 
Enabling agile devliery through enabling BDD in PHP projects
Enabling agile devliery through enabling BDD in PHP projectsEnabling agile devliery through enabling BDD in PHP projects
Enabling agile devliery through enabling BDD in PHP projects
 
Cucumber: How I Slice It
Cucumber: How I Slice ItCucumber: How I Slice It
Cucumber: How I Slice It
 
Largamos o Cucumber!
Largamos o Cucumber!Largamos o Cucumber!
Largamos o Cucumber!
 
Largamos o cucumber
Largamos o cucumberLargamos o cucumber
Largamos o cucumber
 
Introduce cucumber
Introduce cucumberIntroduce cucumber
Introduce cucumber
 
Writing Software not Code with Cucumber
Writing Software not Code with CucumberWriting Software not Code with Cucumber
Writing Software not Code with Cucumber
 
Make Everyone a Tester: Natural Language Acceptance Testing
Make Everyone a Tester: Natural Language Acceptance TestingMake Everyone a Tester: Natural Language Acceptance Testing
Make Everyone a Tester: Natural Language Acceptance Testing
 
Make Everyone a Tester: Natural Language Acceptance Testing
Make Everyone a Tester: Natural Language Acceptance TestingMake Everyone a Tester: Natural Language Acceptance Testing
Make Everyone a Tester: Natural Language Acceptance Testing
 
Fake My Party
Fake My PartyFake My Party
Fake My Party
 
Politics News and U.S. Elections Coverage
Politics News and U.S. Elections CoveragePolitics News and U.S. Elections Coverage
Politics News and U.S. Elections Coverage
 
Quick ref capybara
Quick ref capybaraQuick ref capybara
Quick ref capybara
 
Quick ref capybara
Quick ref capybaraQuick ref capybara
Quick ref capybara
 
Nightline: Late Evening News - ABC News
Nightline: Late Evening News - ABC NewsNightline: Late Evening News - ABC News
Nightline: Late Evening News - ABC News
 
Html5
Html5Html5
Html5
 
Behavior Driven Development with Cucumber
Behavior Driven Development with CucumberBehavior Driven Development with Cucumber
Behavior Driven Development with Cucumber
 
Green Light for the Apps with Calaba.sh - DroidCon Paris 2014
Green Light for the Apps with Calaba.sh - DroidCon Paris 2014Green Light for the Apps with Calaba.sh - DroidCon Paris 2014
Green Light for the Apps with Calaba.sh - DroidCon Paris 2014
 
Solving Real World Problems with YUI 3: AutoComplete
Solving Real World Problems with YUI 3: AutoCompleteSolving Real World Problems with YUI 3: AutoComplete
Solving Real World Problems with YUI 3: AutoComplete
 
Your first website in under a minute with Dancer
Your first website in under a minute with DancerYour first website in under a minute with Dancer
Your first website in under a minute with Dancer
 
U.S. News | National News
U.S. News | National NewsU.S. News | National News
U.S. News | National News
 

Mais de Kang-min Liu

Elasticsearch 實戰介紹
Elasticsearch 實戰介紹Elasticsearch 實戰介紹
Elasticsearch 實戰介紹
Kang-min Liu
 
Same but Different
Same but DifferentSame but Different
Same but Different
Kang-min Liu
 
Good Evils In Perl (Yapc Asia)
Good Evils In Perl (Yapc Asia)Good Evils In Perl (Yapc Asia)
Good Evils In Perl (Yapc Asia)
Kang-min Liu
 
Good Evils In Perl
Good Evils In PerlGood Evils In Perl
Good Evils In Perl
Kang-min Liu
 

Mais de Kang-min Liu (19)

o̍h Tai-gi
o̍h Tai-gio̍h Tai-gi
o̍h Tai-gi
 
The architecture of search engines in Booking.com
The architecture of search engines in Booking.comThe architecture of search engines in Booking.com
The architecture of search engines in Booking.com
 
Elasticsearch 實戰介紹
Elasticsearch 實戰介紹Elasticsearch 實戰介紹
Elasticsearch 實戰介紹
 
Perlbrew
PerlbrewPerlbrew
Perlbrew
 
Same but Different
Same but DifferentSame but Different
Same but Different
 
perlbrew yapcasia 2010
perlbrew yapcasia 2010perlbrew yapcasia 2010
perlbrew yapcasia 2010
 
Git
GitGit
Git
 
Good Evils In Perl (Yapc Asia)
Good Evils In Perl (Yapc Asia)Good Evils In Perl (Yapc Asia)
Good Evils In Perl (Yapc Asia)
 
Learning From Ruby (Yapc Asia)
Learning From Ruby (Yapc Asia)Learning From Ruby (Yapc Asia)
Learning From Ruby (Yapc Asia)
 
YAPC::Tiny Introduction
YAPC::Tiny IntroductionYAPC::Tiny Introduction
YAPC::Tiny Introduction
 
Good Evils In Perl
Good Evils In PerlGood Evils In Perl
Good Evils In Perl
 
Javascript Tutorial
Javascript TutorialJavascript Tutorial
Javascript Tutorial
 
Javascript Basic
Javascript BasicJavascript Basic
Javascript Basic
 
Handlino - RandomLife
Handlino - RandomLifeHandlino - RandomLife
Handlino - RandomLife
 
Jformino
JforminoJformino
Jformino
 
Test Continuous
Test ContinuousTest Continuous
Test Continuous
 
網頁程式還可以怎麼設計
網頁程式還可以怎麼設計網頁程式還可以怎麼設計
網頁程式還可以怎麼設計
 
OSDC.tw 2008 Lightening Talk
OSDC.tw 2008 Lightening TalkOSDC.tw 2008 Lightening Talk
OSDC.tw 2008 Lightening Talk
 
Happy Designer 20080329
Happy Designer 20080329Happy Designer 20080329
Happy Designer 20080329
 

Último

FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377087607
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377087607FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377087607
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377087607
dollysharma2066
 
KLINIK BATA Jual obat penggugur kandungan 087776558899 ABORSI JANIN KEHAMILAN...
KLINIK BATA Jual obat penggugur kandungan 087776558899 ABORSI JANIN KEHAMILAN...KLINIK BATA Jual obat penggugur kandungan 087776558899 ABORSI JANIN KEHAMILAN...
KLINIK BATA Jual obat penggugur kandungan 087776558899 ABORSI JANIN KEHAMILAN...
Cara Menggugurkan Kandungan 087776558899
 
February 2024 Recommendations for newsletter
February 2024 Recommendations for newsletterFebruary 2024 Recommendations for newsletter
February 2024 Recommendations for newsletter
ssuserdfec6a
 
Girls in Mahipalpur (delhi) call me [🔝9953056974🔝] escort service 24X7
Girls in Mahipalpur  (delhi) call me [🔝9953056974🔝] escort service 24X7Girls in Mahipalpur  (delhi) call me [🔝9953056974🔝] escort service 24X7
Girls in Mahipalpur (delhi) call me [🔝9953056974🔝] escort service 24X7
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 

Último (18)

Goregaon West Escorts 🥰 8617370543 Call Girls Offer VIP Hot Girls
Goregaon West Escorts 🥰 8617370543 Call Girls Offer VIP Hot GirlsGoregaon West Escorts 🥰 8617370543 Call Girls Offer VIP Hot Girls
Goregaon West Escorts 🥰 8617370543 Call Girls Offer VIP Hot Girls
 
SIKP311 Sikolohiyang Pilipino - Ginhawa.pptx
SIKP311 Sikolohiyang Pilipino - Ginhawa.pptxSIKP311 Sikolohiyang Pilipino - Ginhawa.pptx
SIKP311 Sikolohiyang Pilipino - Ginhawa.pptx
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377087607
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377087607FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377087607
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377087607
 
KLINIK BATA Jual obat penggugur kandungan 087776558899 ABORSI JANIN KEHAMILAN...
KLINIK BATA Jual obat penggugur kandungan 087776558899 ABORSI JANIN KEHAMILAN...KLINIK BATA Jual obat penggugur kandungan 087776558899 ABORSI JANIN KEHAMILAN...
KLINIK BATA Jual obat penggugur kandungan 087776558899 ABORSI JANIN KEHAMILAN...
 
Call Girls In Mumbai Just Genuine Call ☎ 7738596112✅ Call Girl Andheri East G...
Call Girls In Mumbai Just Genuine Call ☎ 7738596112✅ Call Girl Andheri East G...Call Girls In Mumbai Just Genuine Call ☎ 7738596112✅ Call Girl Andheri East G...
Call Girls In Mumbai Just Genuine Call ☎ 7738596112✅ Call Girl Andheri East G...
 
February 2024 Recommendations for newsletter
February 2024 Recommendations for newsletterFebruary 2024 Recommendations for newsletter
February 2024 Recommendations for newsletter
 
Bokaro Escorts Service Girl ^ 9332606886, WhatsApp Anytime Bokaro
Bokaro Escorts Service Girl ^ 9332606886, WhatsApp Anytime BokaroBokaro Escorts Service Girl ^ 9332606886, WhatsApp Anytime Bokaro
Bokaro Escorts Service Girl ^ 9332606886, WhatsApp Anytime Bokaro
 
Hisar Escorts 🥰 8617370543 Call Girls Offer VIP Hot Girls
Hisar Escorts 🥰 8617370543 Call Girls Offer VIP Hot GirlsHisar Escorts 🥰 8617370543 Call Girls Offer VIP Hot Girls
Hisar Escorts 🥰 8617370543 Call Girls Offer VIP Hot Girls
 
What are some effective methods for increasing concentration and focus while ...
What are some effective methods for increasing concentration and focus while ...What are some effective methods for increasing concentration and focus while ...
What are some effective methods for increasing concentration and focus while ...
 
(JAYA)🎄Low Rate Call Girls Lucknow Call Now 8630512678 Premium Collection Of ...
(JAYA)🎄Low Rate Call Girls Lucknow Call Now 8630512678 Premium Collection Of ...(JAYA)🎄Low Rate Call Girls Lucknow Call Now 8630512678 Premium Collection Of ...
(JAYA)🎄Low Rate Call Girls Lucknow Call Now 8630512678 Premium Collection Of ...
 
March 2023 Recommendations for newsletter
March 2023 Recommendations for newsletterMarch 2023 Recommendations for newsletter
March 2023 Recommendations for newsletter
 
Dadar West Escorts 🥰 8617370543 Call Girls Offer VIP Hot Girls
Dadar West Escorts 🥰 8617370543 Call Girls Offer VIP Hot GirlsDadar West Escorts 🥰 8617370543 Call Girls Offer VIP Hot Girls
Dadar West Escorts 🥰 8617370543 Call Girls Offer VIP Hot Girls
 
Social Learning Theory presentation.pptx
Social Learning Theory presentation.pptxSocial Learning Theory presentation.pptx
Social Learning Theory presentation.pptx
 
2023 - Between Philosophy and Practice: Introducing Yoga
2023 - Between Philosophy and Practice: Introducing Yoga2023 - Between Philosophy and Practice: Introducing Yoga
2023 - Between Philosophy and Practice: Introducing Yoga
 
Colaba Escorts 🥰 8617370543 Call Girls Offer VIP Hot Girls
Colaba Escorts 🥰 8617370543 Call Girls Offer VIP Hot GirlsColaba Escorts 🥰 8617370543 Call Girls Offer VIP Hot Girls
Colaba Escorts 🥰 8617370543 Call Girls Offer VIP Hot Girls
 
Exploring Stoic Philosophy From Ancient Wisdom to Modern Relevance.pdf
Exploring Stoic Philosophy From Ancient Wisdom to Modern Relevance.pdfExploring Stoic Philosophy From Ancient Wisdom to Modern Relevance.pdf
Exploring Stoic Philosophy From Ancient Wisdom to Modern Relevance.pdf
 
Emotional Freedom Technique Tapping Points Diagram.pdf
Emotional Freedom Technique Tapping Points Diagram.pdfEmotional Freedom Technique Tapping Points Diagram.pdf
Emotional Freedom Technique Tapping Points Diagram.pdf
 
Girls in Mahipalpur (delhi) call me [🔝9953056974🔝] escort service 24X7
Girls in Mahipalpur  (delhi) call me [🔝9953056974🔝] escort service 24X7Girls in Mahipalpur  (delhi) call me [🔝9953056974🔝] escort service 24X7
Girls in Mahipalpur (delhi) call me [🔝9953056974🔝] escort service 24X7
 

Integration Test With Cucumber And Webrat

  • 1. Integration Test with Cucumber and Webrat Kang-min Liu gugod@gugod.org
  • 4.
  • 5.
  • 6.
  • 7. : twitter 1. http://twitter.com/home 2. status 3. update 4.
  • 8. Webrat visit "http://twitter.com/home" fill_in "status", :with => "lorem ipsum" click_button "update" response.body.should =~ /lorem ipsum/
  • 11. Webrat • javascript • css
  • 12. Webrat • • Selenium • Watir
  • 13. Webrat Core API • visit • select • click_link • attach_file • fill_in • click_button • check • uncheck • choose
  • 14. Webrat Core API • visit, click_link • get + assert_response :success • click_button • submit form + assert_response :success • submit form default values if any
  • 15. Webrat + RSpec describe "tweeting" do it "should show my tweets" do visit "/home" fill_in "status", :with => "lorem ipsum" click_button "update" response.body.should =~ /lorem ipsum/ end end
  • 16. ?
  • 17. Goods • • HTML •
  • 18. Cucumber • BDD (Behavior Driven Development) Tool • Ruby implementation • •
  • 19. Feature: Update my status In order to keep friends posted As a friendly person I post my status to twitter Scenario: Update my status Given I go to “/home” When I fill in “status” with “lorem ipsum” And I click “send” Then I should see “lorem ipsum”
  • 20. Feature: Update my status In order to keep friends posted As a friendly person I post my status to twitter Scenario: Update my status Given I go to “/home” When I fill in “status” with “lorem ipsum” And I click “send” Then I should see “lorem ipsum”
  • 21. Feature: Update my status In order to keep friends posted As a friendly person I post my status to twitter Scenario: Update my status Given I go to “/home” When I fill in “status” with “lorem ipsum” And I click “send” Then I should see “lorem ipsum”
  • 22. Scenario: Update my status Given I go to “/home” When I fill in “status” with “lorem ipsum” And I click “send” Then I should see “lorem ipsum” Given – When – Then –
  • 23. Given /^I go to "(.*)"$/ do |url| visit url end When /^I fill in "(.*)" with "(.*)"$/ do |field,value| fill_in field, :with => value end When /^I click "(.*)"$/ do |link| click_link(link) end Then /^I should see "(.*)"$/ do |text| response.body.should =~ /#{text}/m end
  • 24. ?
  • 25. Goods... • • • •
  • 27. Scenario: Update my status Given I go to “/home” When I fill in “status” with “lorem ipsum” And I click “send” Then I should see “lorem ipsum”
  • 28. describe "tweeting" do it "should show my tweets" do visit "/home" fill_in "status", :with => "lorem ipsum" click_button "update" response.body.should =~ /lorem ipsum/ end end
  • 29. Reference • Cucumber http://cukes.info/ • Webrat http://github.com/brynary/webrat/ tree/master • Test::Cukes http://search.cpan.org/dist/Test- Cukes/ (Perl implementation)