SlideShare uma empresa Scribd logo
1 de 14
Overview of Cucumber / Capybara
❖ What is BDD?
➢ The main focus is on the expected behavior of the application and it’s
components.
➢ User stories created and maintained collaboratively by all
stakeholders
❖ What are the benefits?
➢ Define verifiable, executable and unambiguous requirements
➢ Developing features that truly add business value
➢ Preventing defects rather than finding defects
➢ Bring QA involvement to the forefront, great for team dynamics
❖ Testing tool based on BDD written in Ruby.
❖ Tests are written in plain language called Gherkin based BDD style of
Given, When, Then, which any layperson can understand.
❖ Tests are grouped into feature files with .feature extension.
➢ E.g. Feature: As a Myish user I should be able to login
Scenario: Successful login
Given I am on the Myish home page
When I fill in email and password
And I click login button
Then I should be able to click on the profile
❖ Capybara is a web-based automation framework used for creating
functional tests that simulate how users would interact with the application
❖ Capybara is library/gem built to be used on top of underlying web-based
driver
❖ Offers user-friendly DSL ( Domain Specific Language )
❖ Supported driver
➢ Rack::test
■ Default driver. No JavaScript support
➢ Selenium-Webdriver
■ Mostly used in web-based automation FW
➢ Capybara-Webkit
■ For true headless testing with JavaScript support
❖ Basic DSL :
➢ Visit('page_url') # navigate to page
➢ Click_link('id_of_link') # click link by id
➢ Click_link('link_text') # click link by link text
➢ Click_button('button_name') # fill text field
➢ Fill_in('First Name', :with => 'John') # choose radio button
➢ Choose('radio_button') # choose radio button
➢ Check('checkbox') # check in checkbox
➢ Uncheck('checkbox') # uncheck in checkbox
➢ Select('option', :from=>'select_box') # select from dropdown
➢ Attach_file('image', 'path_to_image') # upload file
❖ Java - JRE
❖ Ruby
❖ RubyGems installation – use “gem install <name of gem>” command.
➢ Cucumber
➢ Capybara
➢ Rspec
Project Structure :
Project Structure :
Features – folder to host all your feature files.
Step_Definitions – folder to host all your step definition Ruby files.
Support – folder to host your configuration files (env.rb).
Gemfile – defines the top-level gems to be used in your project.
Sample: simple_search.feature:
– Describes the features that a user will be able to use in the program.
Feature: As a user I should be able to perform simple google search.
Scenario: A simple google search scenario
Given I am on the main google search
When I fill in "q" with "Cucumber test"
And I click "gbqfb" button
And I click on the first result
Then I should see "Cucumber lets software development teams describe
how software should behave in plain text."
Given /^I am on the main google search$/ do
visit ('/')
end
When /^(?:|I )fill in "([^"]*)" with "([^"]*)"$/ do |field, value|
fill_in(field, :with => value)
end
Then /^I click "([^"]*)" button$/ do |button|
click_button(button)
end
Then /^I click on the first result$/ do
find(:xpath, "//html/body/div[3]/div[2]/div/div[5]/div[2]/div[2]/div/div[2]/div/ol/li/div/h3/a").click
end
Then /^I should see "([^"]*)"$/ do |text|
page.should have_content(text)
end
Project structure :
require 'capybara'
require 'capybara/cucumber'
Capybara.default_driver = :selenium
Capybara.app_host = "http://www.google.com"
Capybara.default_wait_time = 20
World(Capybara)
source "http://rubygems.org"
group(:test) do
gem 'cucumber'
gem 'capybara'
gem 'rspec'
end
command to run the script :
cucumber features/<name of the feature file>.feature
command to generate the report:
run this command by going to your project directory
cucumber features --format html --out reports
https://github.com/jnicklas/capybara
https://shvets.github.io/blog/2013/10/12/acceptance_tricks.html
https://github.com/cucumber/cucumber/wiki
http://www.ibm.com/developerworks/library/a-automating-ria/
Useful resources (and lots of examples):
http://books.openlibra.com/pdf/cuke4ninja-2011-03-16.pdf < awesome free
eBook – fun to read, too.
http://www.slideshare.net/lunivore/behavior-driven-development-11754474 <
Liz really knows her stuff!
http://dannorth.net/2011/01/31/whose-domain-is-it-anyway/
https://www.google.co.uk/search?q=declarative+vs+imperative+BDD < go
Team Declarative!

Mais conteúdo relacionado

Mais procurados

BDD in Action – principles, practices and real-world application
BDD in Action – principles, practices and real-world applicationBDD in Action – principles, practices and real-world application
BDD in Action – principles, practices and real-world application
John Ferguson Smart Limited
 

Mais procurados (20)

Introduction to Bdd and cucumber
Introduction to Bdd and cucumberIntroduction to Bdd and cucumber
Introduction to Bdd and cucumber
 
Introduction to BDD
Introduction to BDDIntroduction to BDD
Introduction to BDD
 
Test Automation Framework with BDD and Cucumber
Test Automation Framework with BDD and CucumberTest Automation Framework with BDD and Cucumber
Test Automation Framework with BDD and Cucumber
 
Cucumber & gherkin language
Cucumber & gherkin languageCucumber & gherkin language
Cucumber & gherkin language
 
Selenium with Cucumber
Selenium  with Cucumber Selenium  with Cucumber
Selenium with Cucumber
 
Cucumber BDD
Cucumber BDDCucumber BDD
Cucumber BDD
 
Test and Behaviour Driven Development (TDD/BDD)
Test and Behaviour Driven Development (TDD/BDD)Test and Behaviour Driven Development (TDD/BDD)
Test and Behaviour Driven Development (TDD/BDD)
 
Successfully Implementing BDD in an Agile World
Successfully Implementing BDD in an Agile WorldSuccessfully Implementing BDD in an Agile World
Successfully Implementing BDD in an Agile World
 
BDD in Action – principles, practices and real-world application
BDD in Action – principles, practices and real-world applicationBDD in Action – principles, practices and real-world application
BDD in Action – principles, practices and real-world application
 
BDD with Cucumber
BDD with CucumberBDD with Cucumber
BDD with Cucumber
 
What Is Cucumber?
What Is Cucumber?What Is Cucumber?
What Is Cucumber?
 
Test Automation Framework using Cucumber BDD overview (part 1)
Test Automation Framework using Cucumber BDD overview (part 1)Test Automation Framework using Cucumber BDD overview (part 1)
Test Automation Framework using Cucumber BDD overview (part 1)
 
Behavior Driven Development (BDD)
Behavior Driven Development (BDD)Behavior Driven Development (BDD)
Behavior Driven Development (BDD)
 
Bdd and spec flow
Bdd and spec flowBdd and spec flow
Bdd and spec flow
 
BDD presentation
BDD presentationBDD presentation
BDD presentation
 
Cucumber ppt
Cucumber pptCucumber ppt
Cucumber ppt
 
Test automation with Cucumber-JVM
Test automation with Cucumber-JVMTest automation with Cucumber-JVM
Test automation with Cucumber-JVM
 
Automated Test Framework with Cucumber
Automated Test Framework with CucumberAutomated Test Framework with Cucumber
Automated Test Framework with Cucumber
 
Behavior Driven Development Pros and Cons
Behavior Driven Development Pros and ConsBehavior Driven Development Pros and Cons
Behavior Driven Development Pros and Cons
 
BDD: The unit test of the product owner
BDD: The unit test of the product ownerBDD: The unit test of the product owner
BDD: The unit test of the product owner
 

Semelhante a Behavior Driven Development Testing (BDD)

Ruby onrails cucumber-rspec-capybara
Ruby onrails cucumber-rspec-capybaraRuby onrails cucumber-rspec-capybara
Ruby onrails cucumber-rspec-capybara
Bindesh Vijayan
 

Semelhante a Behavior Driven Development Testing (BDD) (20)

BDD / cucumber /Capybara
BDD / cucumber /CapybaraBDD / cucumber /Capybara
BDD / cucumber /Capybara
 
cucumber harpal.pdf
cucumber harpal.pdfcucumber harpal.pdf
cucumber harpal.pdf
 
Tutorial on the integration of Selenium with cucumber for experts and fresher’s
Tutorial on the integration of Selenium with cucumber for experts and fresher’sTutorial on the integration of Selenium with cucumber for experts and fresher’s
Tutorial on the integration of Selenium with cucumber for experts and fresher’s
 
Cucumber
CucumberCucumber
Cucumber
 
Cucumber
CucumberCucumber
Cucumber
 
BDD Selenium for Agile Teams - User Stories
BDD Selenium for Agile Teams - User StoriesBDD Selenium for Agile Teams - User Stories
BDD Selenium for Agile Teams - User Stories
 
2014 11 20 Drupal 7 -> 8 test migratie
2014 11 20 Drupal 7 -> 8 test migratie2014 11 20 Drupal 7 -> 8 test migratie
2014 11 20 Drupal 7 -> 8 test migratie
 
Ruby onrails cucumber-rspec-capybara
Ruby onrails cucumber-rspec-capybaraRuby onrails cucumber-rspec-capybara
Ruby onrails cucumber-rspec-capybara
 
Behavior Driven Development by Example
Behavior Driven Development by ExampleBehavior Driven Development by Example
Behavior Driven Development by Example
 
Perl Behavior Driven Development (BDD)
Perl Behavior Driven Development (BDD)Perl Behavior Driven Development (BDD)
Perl Behavior Driven Development (BDD)
 
The "Holy Grail" of Dev/Ops
The "Holy Grail" of Dev/OpsThe "Holy Grail" of Dev/Ops
The "Holy Grail" of Dev/Ops
 
Testing with cucumber testing framework
Testing with cucumber testing frameworkTesting with cucumber testing framework
Testing with cucumber testing framework
 
Visual Regression Testing: In search of an Ember solution
Visual Regression Testing: In search of an Ember solutionVisual Regression Testing: In search of an Ember solution
Visual Regression Testing: In search of an Ember solution
 
Capybara and cucumber with DSL using ruby
Capybara and cucumber with DSL using rubyCapybara and cucumber with DSL using ruby
Capybara and cucumber with DSL using ruby
 
Devops
DevopsDevops
Devops
 
Dalek.js - Automated cross browser testing with JavaScript
Dalek.js - Automated cross browser testing with JavaScriptDalek.js - Automated cross browser testing with JavaScript
Dalek.js - Automated cross browser testing with JavaScript
 
End-to-end web-testing in ruby ecosystem
End-to-end web-testing in ruby ecosystemEnd-to-end web-testing in ruby ecosystem
End-to-end web-testing in ruby ecosystem
 
Buildr - build like you code
Buildr -  build like you codeBuildr -  build like you code
Buildr - build like you code
 
Andrea Di Persio
Andrea Di PersioAndrea Di Persio
Andrea Di Persio
 
End to end testing Single Page Apps & APIs with Cucumber.js and Puppeteer (Em...
End to end testing Single Page Apps & APIs with Cucumber.js and Puppeteer (Em...End to end testing Single Page Apps & APIs with Cucumber.js and Puppeteer (Em...
End to end testing Single Page Apps & APIs with Cucumber.js and Puppeteer (Em...
 

Mais de Dignitas Digital Pvt. Ltd.

Mais de Dignitas Digital Pvt. Ltd. (16)

Emotions in Marketing | Understanding Emotions In The Marketing.
Emotions in Marketing | Understanding Emotions In The Marketing.Emotions in Marketing | Understanding Emotions In The Marketing.
Emotions in Marketing | Understanding Emotions In The Marketing.
 
Affiliate marketing
Affiliate marketingAffiliate marketing
Affiliate marketing
 
Visual Content Marketing
Visual Content MarketingVisual Content Marketing
Visual Content Marketing
 
An Ideal Sales Cycle
An Ideal Sales CycleAn Ideal Sales Cycle
An Ideal Sales Cycle
 
Website audit for SEO
Website audit for SEOWebsite audit for SEO
Website audit for SEO
 
What is Ethical Hacking?
What is Ethical Hacking? What is Ethical Hacking?
What is Ethical Hacking?
 
Infographics
InfographicsInfographics
Infographics
 
Marketing Tools & Strategies
Marketing Tools & StrategiesMarketing Tools & Strategies
Marketing Tools & Strategies
 
LinkedIn marketing
LinkedIn marketingLinkedIn marketing
LinkedIn marketing
 
Rooting android
Rooting androidRooting android
Rooting android
 
UI / UX Design Presentation
UI / UX Design PresentationUI / UX Design Presentation
UI / UX Design Presentation
 
The Project ARA
The Project ARAThe Project ARA
The Project ARA
 
Ease of doing business in India and Agile Methodology
Ease of doing business in India and Agile MethodologyEase of doing business in India and Agile Methodology
Ease of doing business in India and Agile Methodology
 
Customer Relationship Management (CRM)
Customer Relationship Management (CRM)Customer Relationship Management (CRM)
Customer Relationship Management (CRM)
 
Digital Marketing & Advertising
Digital Marketing & AdvertisingDigital Marketing & Advertising
Digital Marketing & Advertising
 
DIY! Introduction to Arduino (Development Board)
DIY! Introduction to Arduino (Development Board) DIY! Introduction to Arduino (Development Board)
DIY! Introduction to Arduino (Development Board)
 

Último

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Último (20)

Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 

Behavior Driven Development Testing (BDD)

  • 1. Overview of Cucumber / Capybara
  • 2. ❖ What is BDD? ➢ The main focus is on the expected behavior of the application and it’s components. ➢ User stories created and maintained collaboratively by all stakeholders ❖ What are the benefits? ➢ Define verifiable, executable and unambiguous requirements ➢ Developing features that truly add business value ➢ Preventing defects rather than finding defects ➢ Bring QA involvement to the forefront, great for team dynamics
  • 3. ❖ Testing tool based on BDD written in Ruby. ❖ Tests are written in plain language called Gherkin based BDD style of Given, When, Then, which any layperson can understand. ❖ Tests are grouped into feature files with .feature extension. ➢ E.g. Feature: As a Myish user I should be able to login Scenario: Successful login Given I am on the Myish home page When I fill in email and password And I click login button Then I should be able to click on the profile
  • 4. ❖ Capybara is a web-based automation framework used for creating functional tests that simulate how users would interact with the application ❖ Capybara is library/gem built to be used on top of underlying web-based driver ❖ Offers user-friendly DSL ( Domain Specific Language ) ❖ Supported driver ➢ Rack::test ■ Default driver. No JavaScript support ➢ Selenium-Webdriver ■ Mostly used in web-based automation FW ➢ Capybara-Webkit ■ For true headless testing with JavaScript support
  • 5. ❖ Basic DSL : ➢ Visit('page_url') # navigate to page ➢ Click_link('id_of_link') # click link by id ➢ Click_link('link_text') # click link by link text ➢ Click_button('button_name') # fill text field ➢ Fill_in('First Name', :with => 'John') # choose radio button ➢ Choose('radio_button') # choose radio button ➢ Check('checkbox') # check in checkbox ➢ Uncheck('checkbox') # uncheck in checkbox ➢ Select('option', :from=>'select_box') # select from dropdown ➢ Attach_file('image', 'path_to_image') # upload file
  • 6. ❖ Java - JRE ❖ Ruby ❖ RubyGems installation – use “gem install <name of gem>” command. ➢ Cucumber ➢ Capybara ➢ Rspec
  • 8. Project Structure : Features – folder to host all your feature files. Step_Definitions – folder to host all your step definition Ruby files. Support – folder to host your configuration files (env.rb). Gemfile – defines the top-level gems to be used in your project.
  • 9. Sample: simple_search.feature: – Describes the features that a user will be able to use in the program. Feature: As a user I should be able to perform simple google search. Scenario: A simple google search scenario Given I am on the main google search When I fill in "q" with "Cucumber test" And I click "gbqfb" button And I click on the first result Then I should see "Cucumber lets software development teams describe how software should behave in plain text."
  • 10. Given /^I am on the main google search$/ do visit ('/') end When /^(?:|I )fill in "([^"]*)" with "([^"]*)"$/ do |field, value| fill_in(field, :with => value) end Then /^I click "([^"]*)" button$/ do |button| click_button(button) end Then /^I click on the first result$/ do find(:xpath, "//html/body/div[3]/div[2]/div/div[5]/div[2]/div[2]/div/div[2]/div/ol/li/div/h3/a").click end Then /^I should see "([^"]*)"$/ do |text| page.should have_content(text) end
  • 11. Project structure : require 'capybara' require 'capybara/cucumber' Capybara.default_driver = :selenium Capybara.app_host = "http://www.google.com" Capybara.default_wait_time = 20 World(Capybara)
  • 12. source "http://rubygems.org" group(:test) do gem 'cucumber' gem 'capybara' gem 'rspec' end
  • 13. command to run the script : cucumber features/<name of the feature file>.feature command to generate the report: run this command by going to your project directory cucumber features --format html --out reports
  • 14. https://github.com/jnicklas/capybara https://shvets.github.io/blog/2013/10/12/acceptance_tricks.html https://github.com/cucumber/cucumber/wiki http://www.ibm.com/developerworks/library/a-automating-ria/ Useful resources (and lots of examples): http://books.openlibra.com/pdf/cuke4ninja-2011-03-16.pdf < awesome free eBook – fun to read, too. http://www.slideshare.net/lunivore/behavior-driven-development-11754474 < Liz really knows her stuff! http://dannorth.net/2011/01/31/whose-domain-is-it-anyway/ https://www.google.co.uk/search?q=declarative+vs+imperative+BDD < go Team Declarative!