SlideShare a Scribd company logo
BEHAVIOR-DRIVEN DEVELOPMENT (BDD)
AND AUTOMATION TESTING WITH CUCUMBER
November 2013
KMS Technology: http://kms-technology.com
1
SAMPLE REQUIREMENT
Feature: login to the system.
As a user,
I want to login into the system when I provide username and
password.
Scenario: login successfully
Given the login page is opening
When I input username into the username textbox
And I input valid password into the password textbox
And I click Login button
Then I am on the Home page
2
AUTOMATION TEST
@Test
public void fb_login_test() throws Exception {
driver.get("https://www.facebook.com/");
driver.findElement(By.id("email")).clear();
driver.findElement(By.id("email")).sendKeys("bddtest@yahoo.com");
driver.findElement(By.id("pass")).clear();
driver.findElement(By.id("pass")).sendKeys("********");
driver.findElement(By.id("u_0_e")).click();
}
3
HOW?
4
AGENDA
BDD and Agile Development Practice
Automation Testing with Cucumber
Developing Cucumber-Based Automation
Framework
BDD/Cucumber – Pros & Cons
5
HOW WE ENGAGE, WHY WE ARE YOUR
BEST PARTNER….
Bright Minds, Brilliant Solutions
6
BDD & AGILE DEVELOPMENT
PRACTICE
BEHAVIOR-DRIVEN DEVELOPMENT
7
GIVEN, WHEN, THEN
8
BDD AND AGILE DEVELOPMENT
PRACTICE
9
HOW WE ENGAGE, WHY WE ARE YOUR
BEST PARTNER….
Bright Minds, Brilliant Solutions
10
AUTOMATION TESTING WITH
CUCUMBER
CUCUMBER APPROACH
11
Given /^I launch "([^"]*)" page$/ do |page|
visit(page)
End
When /^I fill in "([^"]*)" with "([^"]*)"$/ do |field, value|
fill_in field, :with => value
end
SCENARIO EXAMPLE
IN BDD FORMAT
Feature: login to the system.
As a user, I want to login into the system when I provide username and
password.
@tag_login_email
Scenario Outline: Verify that can login gmail
Given I launch "https://accounts.google.com" page
When I fill in “Email " with “<Email >"
And I fill in “Passwd" with "<Password> "
And I click on "signIn" button
Then I am on the “Home” page
Scenarios:
| Email | Password |
| kms.admin@gmail.com | kms@2013 |
| kms.user@gmail.com | kms@1234 |
12
HOW CUCUMBER EXECUTE A
SCENARIO
13
SUMMARY
14
TESTING AREA
Web application
Web services
• Desktop application
– http://pragprog.com/book/idgtr/scripted-gui-testing-with-ruby
• Mobile application
– http://www.moncefbelyamani.com/ios-automated-testing-with-calabash-cucumber-ruby/
15
CASE STUDY
Complete 70% automation testing following
agile process for a Healthcare Data Provider
Client:
– Health Market Science (HMS)
Business Challenges:
– 90% automation testing must be done for every 4-
week sprint
– Big Data Technology – Since MySQL, Oracle to
NoSQL, Cassandra, Storm, Hadoop
– Complicated test data creation
16
INSTALLATION
• Ruby:
– Windows: http://rubyinstaller.org/
– Linux: https://rvm.io/rvm/install
• Cucumber:
• gem install cucumber
http://rubygems.org/gems/cucumber
17
DEMO
• Web application:
Cucumber + Capybara
• Web Services:
Cucumber + HTTParty + Savon
18
DEMO: WEB APPLICATION
19
Cucumber Capybara
Selenium
WebDriver
Poltergeist
phantomjs
20
DEMO: WEB APPLICATION
21
Navigating
• (Object) visit(url)
– The request method is always GET.
– url (String) - The relative/absolute URL to navigate to.
– Examples:
• visit('http://google.com')
DEMO: WEB APPLICATION
22
Navigating
Action
• (Object) click_link(locator, options = {})
– Finds a link by id or text and clicks it.
• (Object) click_button(locator, options = {})
– Finds a button by id, text or value and clicks it.
• (Object) fill_in(locator, options = {})
– Locate a text field or text area. The field can be found via its
name, id or label text.
DEMO: WEB APPLICATION
23
Navigating
Action
Check Point
• (Boolean) has_content?(content) /
• (Boolean) has_no_content?(content)
– content (String) - The text to check for
– Examples:
• page.has_content?(‘hello’)
• page.has_no_content?(‘hello’)
DEMO: WEB APPLICATION
24
Navigating
Action
Check Point
• RSpec magic matchers
– page.should have_selector('table tr')
– page.should have_no_selector(:content)
– page.should have_css('table tr.foo')
– page.should have_content('foo')
DEMO: WEB APPLICATION
DEMO: WEB APPLICATION
Regular ExpressionRegular Expression
Regular Expression
DEMO: WEB APPLICATION
HOW WE ENGAGE, WHY WE ARE YOUR
BEST PARTNER….
Bright Minds, Brilliant Solutions
27
TAKE A REST
DEMO
• Web Services:
Cucumber + HTTParty + Savon
28
DEMO: WEB SERVICES
29
• At a glance:
RESTful
Web
Service
SOAP Web
Service
HTTParty/
RestClient
/Json
Savon
Libs
Cukes!
GET/POST:
Content: JSON
{“data_id”:”1001”,
“active”:”yes”
“age”:”29”}
GET/POST:
Content: XML
<SOAP:Env xlms…
<data_id>1001</data_id>
<active>yes</active>
<age>29</age>
</SOAP:Env>
DEMO: WEB SERVICES
HTTParty
HTTParty.get 'http://myexample.com/newfeeds‘
 Response.body={“id”:”100”,”Message”:”Hello”}
HTTParty.post 'http://myexample.com/updateStatus',
{:date => “Nov-11-2013”, :status => “Full of energy
today”}
 Response.body={“update”:”success”,”id”:”425”}
HTTParty.put 'http://myexample.com/status/message’,
{:timeout => 5000}
 Response.body={“success”:”true”,”message”:”me
ssage_1377057406713”}
HTTParty.delete
'http://myexample.com/status/message_13770574067
14‘
=> Response.body={“success”:”false”,”reason”:”non-
exist”}
30
JSON
ActualRslt = JSON.parse(response.body)
Msg1 = ActualRslt[“message”] #= “Hello”
ActualRslt = JSON.parse(response.body)
Msg1 = ActualRslt[“update”] #= “success”
ActualRslt = JSON.parse(response.body)
Msg1 = ActualRslt[“message”]
#= “message_1377057406713”
ActualRslt = JSON.parse(response.body)
Msg1 = ActualRslt[“success”] #= “false”
Msg1 = ActualRslt[“reason”] #= “non-exist”
DEMO: WEB SERVICES
Savon
# create a client for the service
client = Savon.client(wsdl:
'http://service.example.com?wsdl')
client.operations
=> [:find_user, :list_users]
# call the 'findUser' operation
response = client.call(:find_user,
message: { id: 42 })
31
actualRes = response.xml
<?xml version="1.0" encoding="utf-
8"?><soap:Envelope....XMLSchema">
<soap:Body><findUserResponse
xmlns="http://service.example.com">
<findUserResult><Success>true</Success>
<LastName>Smith</LastName>
<FirstName>John</FirstName>
<City>Mountain View</City>
<State>CA</State><WeatherID>
</findUserResult></findUserResponse>
</soap:Body></soap:Envelope>
DEMO: WEB SERVICES
Feature: Get Weather status to display on webpage
As an owner of Traveling Service, I want to be able to get weather status of any
location based on address of client's request
Scenario Outline: Get weather status by address of client's requests
Given The check IP location and weather web services are running
When I send request to get location detail of address "<Address>"
Then I should have ZIP code and "<Country>" of that location
And I send request to get weather status of that location by its ZIP code
Then I should receive current "Temperature, Wind, RelativeHumidity" and "<City_Name>"
and "<State>" of that location
Scenarios:
|Address |Country |City_Name |State |
|www.google.com |United States |Mountain View |California |
32
HOW WE ENGAGE, WHY WE ARE YOUR
BEST PARTNER….
Bright Minds, Brilliant Solutions
33
DEVELOPING CUCUMBER-BASED
AUTOMATION FRAMEWORK
DEVELOPING CUCUMBER-BASED
AUTOMATION FRAMEWORK
34
Web Service UIDatabase
Step Library & Object Definition
Environment Configuration
Web
driver
(IE,CH,FF)
Cassandra
MySQL
Oracle
RESTful
WS
SOAP
WS
Test
Data
Repo.
Reports
/Logs
CORE LAYER
Feature Repository Test
Execution
Tester A Tester B Tester C Tester D
TRANSLATION LAYER
DESCRIPTION LAYER
Web
Apps
OCI8,
Cassandra
HTTParty
Savon, JSON
Openssl
Capybara
Xmlparser
……….
DEVELOPING CUCUMBER-BASED
AUTOMATION FRAMEWORK
35
Web Service UIDatabase
Step Library & Object Definition
Environment Configuration
Web
driver
(IE,CH,FF)
Cassandra
MySQL
Oracle
RESTful
WS
SOAP
WS
Test
Data
Repo.
Reports
/Logs
CORE LAYER
Feature Repository Test
Execution
Tester A Tester B Tester C Tester D
TRANSLATION LAYER
DESCRIPTION LAYER
Web
Apps
OCI8,
Cassandra
HTTParty
Savon, JSON
Openssl
Capybara
Xmlparser
……….
DEVELOPING CUCUMBER-BASED
AUTOMATION FRAMEWORK
36
Web Service UIDatabase
Step Library & Object Definition
Environment Configuration
Web
driver
(IE,CH,FF)
Cassandra
MySQL
Oracle
RESTful
WS
SOAP
WS
Test
Data
Repo.
Reports
/Logs
CORE LAYER
Feature Repository Test
Execution
Tester A Tester B Tester C Tester D
TRANSLATION LAYER
DESCRIPTION LAYER
Web
Apps
OCI8,
Cassandra
HTTParty
Savon, JSON
Openssl
Capybara
Xmlparser
……….
DEVELOPING CUCUMBER-BASED
AUTOMATION FRAMEWORK
37
Web Service UIDatabase
Step Library & Object Definition
Environment Configuration
Web
driver
(IE,CH,FF)
Cassandra
MySQL
Oracle
RESTful
WS
SOAP
WS
Test
Data
Repo.
Reports
/Logs
CORE LAYER
Feature Repository Test
Execution
Tester A Tester B Tester C Tester D
TRANSLATION LAYER
DESCRIPTION LAYER
Web
Apps
OCI8,
Cassandra
HTTParty
Savon, JSON
Openssl
Capybara
Xmlparser
……….
DEVELOPING CUCUMBER-BASED
AUTOMATION FRAMEWORK
38
Web Service UIDatabase
Step Library & Object Definition
Environment Configuration
Web
driver
(IE,CH,FF)
Cassandra
MySQL
Oracle
RESTful
WS
SOAP
WS
Test
Data
Repo.
Reports
/Logs
CORE LAYER
Feature Repository Test
Execution
Tester A Tester B Tester C Tester D
TRANSLATION LAYER
DESCRIPTION LAYER
Web
Apps
OCI8,
Cassandra
HTTParty
Savon, JSON
Openssl
Capybara
Xmlparser
……….
39
DEVELOPING CUCUMBER-BASED
AUTOMATION FRAMEWORK
A Hybrid Test Automation Framework
Keyword-Driven
Test Library
Architecture
Functional
Decomposition
Data-Driven
Object Action Argument
Login.txt_usr set myname
Login.txt_pwd set mypass
Login.btn_sign click
Framework
Method
HOW WE ENGAGE, WHY WE ARE YOUR
BEST PARTNER….
Bright Minds, Brilliant Solutions
40
BDD/CUCUMBER – PROS & CONS
41
BDD/CUCUMBER - PROS
 BBD is FRIENDLY and UNDERSTANDABLE by non-
technical User
 Great support from RUBY community - Automation
framework based BDD Cucumber is NOT REALLY
HARD to develop and maintenance
 Support on MULTIPLE PLATFORM, OS and different
browsers
42
BDD/CUCUMBER - CONS
 Incompatibility among GEM versions
 Lacking of tool for managing Features and
Scenarios effectively
ARE YOUR BEST PARTNER….
Bright Minds, Brilliant Solutions
43
Q&A
© 2013 KMS Technology
THANK YOU
44
REFERENCES
45
• All about BDD Cucumber: http://cukes.info/
• BDD cucumber book: http://www.amazon.com/The-Cucumber-
Book-Behaviour-Driven-Development/dp/1934356808
• Ruby gems: http://rubygems.org
• Ruby programming: http://www.ruby-lang.org

More Related Content

PDF
BDD & Cucumber
Vladimir Arutin
 
PPTX
Test Automation Framework with BDD and Cucumber
Rhoynar Software Consulting
 
ODP
BDD with Cucumber
Knoldus Inc.
 
PPTX
Cucumber BDD
Pravin Dsilva
 
PPTX
Automation test framework with cucumber – BDD
123abcda
 
PPSX
Cucumber & gherkin language
selvanathankapilan
 
PPTX
Automated Test Framework with Cucumber
Ramesh Krishnan Ganesan
 
PPT
Web Test Automation with Selenium
vivek_prahlad
 
BDD & Cucumber
Vladimir Arutin
 
Test Automation Framework with BDD and Cucumber
Rhoynar Software Consulting
 
BDD with Cucumber
Knoldus Inc.
 
Cucumber BDD
Pravin Dsilva
 
Automation test framework with cucumber – BDD
123abcda
 
Cucumber & gherkin language
selvanathankapilan
 
Automated Test Framework with Cucumber
Ramesh Krishnan Ganesan
 
Web Test Automation with Selenium
vivek_prahlad
 

What's hot (20)

PPTX
Automation Testing by Selenium Web Driver
Cuelogic Technologies Pvt. Ltd.
 
PPTX
BDD WITH CUCUMBER AND JAVA
Srinivas Katakam
 
PPT
Test Automation Framework Designs
Sauce Labs
 
PPTX
Bdd – with cucumber and gherkin
Arati Joshi
 
ODP
Test Automation Framework using Cucumber BDD overview (part 1)
Mindfire Solutions
 
PPTX
Introduction to Bdd and cucumber
Nibu Baby
 
PPTX
Test Automation and Selenium
Karapet Sarkisyan
 
PPTX
Test automation
Xavier Yin
 
PPTX
Cucumber presenation
Oussama BEN WAFI
 
PDF
Selenium with Cucumber
Knoldus Inc.
 
PDF
Cucumber ppt
Qwinix Technologies
 
PDF
Getting Started With Cypress
Knoldus Inc.
 
PPTX
Test automation proposal
Mihai-Cristian Fratila
 
PDF
TDD and BDD and ATDD
Anuar Nurmakanov
 
PPTX
Microservices
SmartBear
 
PDF
An Introduction To Automated API Testing
Sauce Labs
 
PDF
Introduction to CICD
Knoldus Inc.
 
PPTX
Automation - web testing with selenium
Tzirla Rozental
 
PPTX
Introduction to microservices
Paulo Gandra de Sousa
 
Automation Testing by Selenium Web Driver
Cuelogic Technologies Pvt. Ltd.
 
BDD WITH CUCUMBER AND JAVA
Srinivas Katakam
 
Test Automation Framework Designs
Sauce Labs
 
Bdd – with cucumber and gherkin
Arati Joshi
 
Test Automation Framework using Cucumber BDD overview (part 1)
Mindfire Solutions
 
Introduction to Bdd and cucumber
Nibu Baby
 
Test Automation and Selenium
Karapet Sarkisyan
 
Test automation
Xavier Yin
 
Cucumber presenation
Oussama BEN WAFI
 
Selenium with Cucumber
Knoldus Inc.
 
Cucumber ppt
Qwinix Technologies
 
Getting Started With Cypress
Knoldus Inc.
 
Test automation proposal
Mihai-Cristian Fratila
 
TDD and BDD and ATDD
Anuar Nurmakanov
 
Microservices
SmartBear
 
An Introduction To Automated API Testing
Sauce Labs
 
Introduction to CICD
Knoldus Inc.
 
Automation - web testing with selenium
Tzirla Rozental
 
Introduction to microservices
Paulo Gandra de Sousa
 
Ad

Similar to Behavior Driven Development and Automation Testing Using Cucumber (20)

PDF
Behavioral Driven Development
Cprime
 
PPTX
BDD / cucumber /Capybara
ShraddhaSF
 
PPTX
Introduce cucumber
Bachue Zhou
 
PDF
Behavior-Driven Development and Automation Testing Using Cucumber Framework W...
KMS Technology
 
PPTX
Cucumber_Training_ForQA
Meenakshi Singhal
 
PDF
cucumber harpal.pdf
VennelaVasupilli
 
PDF
Testing stage. being ahead business with cucumber
Alex Mikitenko
 
PDF
Ruby onrails cucumber-rspec-capybara
Bindesh Vijayan
 
PDF
Mastering BDD with Cucumber & Java for Test Automation
digitaljignect
 
PDF
Behavior Driven Development with Cucumber
Brandon Keepers
 
PDF
Cucumber tutorial
HarikaReddy115
 
KEY
Cucumber
Michael MacDonald
 
PPTX
Behavior Driven Development Testing (BDD)
Dignitas Digital Pvt. Ltd.
 
PPTX
Behavior Driven Development - TdT@Cluj #15
Tabăra de Testare
 
PPTX
Bdd with Cucumber and Mocha
Atish Narlawar
 
PDF
BDD in Java using Cucumber
slavkurochkin
 
PPTX
Hands on BDD with cucumber - Agile Goa Sept 2013
Sonik Chopra
 
PPTX
BDD Selenium for Agile Teams - User Stories
Sauce Labs
 
PPT
Selenium and Cucumber Selenium Conf 2011
dimakovalenko
 
PPT
Cucumber Presentation Kiev Meet Up
dimakovalenko
 
Behavioral Driven Development
Cprime
 
BDD / cucumber /Capybara
ShraddhaSF
 
Introduce cucumber
Bachue Zhou
 
Behavior-Driven Development and Automation Testing Using Cucumber Framework W...
KMS Technology
 
Cucumber_Training_ForQA
Meenakshi Singhal
 
cucumber harpal.pdf
VennelaVasupilli
 
Testing stage. being ahead business with cucumber
Alex Mikitenko
 
Ruby onrails cucumber-rspec-capybara
Bindesh Vijayan
 
Mastering BDD with Cucumber & Java for Test Automation
digitaljignect
 
Behavior Driven Development with Cucumber
Brandon Keepers
 
Cucumber tutorial
HarikaReddy115
 
Behavior Driven Development Testing (BDD)
Dignitas Digital Pvt. Ltd.
 
Behavior Driven Development - TdT@Cluj #15
Tabăra de Testare
 
Bdd with Cucumber and Mocha
Atish Narlawar
 
BDD in Java using Cucumber
slavkurochkin
 
Hands on BDD with cucumber - Agile Goa Sept 2013
Sonik Chopra
 
BDD Selenium for Agile Teams - User Stories
Sauce Labs
 
Selenium and Cucumber Selenium Conf 2011
dimakovalenko
 
Cucumber Presentation Kiev Meet Up
dimakovalenko
 
Ad

More from KMS Technology (20)

PDF
A journey to a Full Stack Tester
KMS Technology
 
PDF
React & Redux, how to scale?
KMS Technology
 
PDF
Sexy React Stack
KMS Technology
 
PDF
Common design principles and design patterns in automation testing
KMS Technology
 
PDF
[Webinar] Test First, Fail Fast - Simplifying the Tester's Transition to DevOps
KMS Technology
 
PDF
KMSNext Roadmap
KMS Technology
 
PDF
KMS Introduction
KMS Technology
 
PDF
What's new in the Front-end development nowadays?
KMS Technology
 
PDF
JavaScript - No Longer A Toy Language
KMS Technology
 
PDF
JavaScript No longer A “toy” Language
KMS Technology
 
PDF
Preparations For A Successful Interview
KMS Technology
 
PDF
Introduction To Single Page Application
KMS Technology
 
PDF
AWS: Scaling With Elastic Beanstalk
KMS Technology
 
PDF
KMS Introduction
KMS Technology
 
PDF
Technology Application Development Trends For IT Students
KMS Technology
 
PDF
Contributors for Delivering a Successful Testing Project Seminar
KMS Technology
 
PDF
Increase Chances to Be Hired as Software Developers - 2014
KMS Technology
 
PDF
Software Technology Trends in 2013-2014
KMS Technology
 
PDF
Cross-platform Mobile Development with C# and Xamarin Webinar
KMS Technology
 
PDF
Software Testing Process & Trend
KMS Technology
 
A journey to a Full Stack Tester
KMS Technology
 
React & Redux, how to scale?
KMS Technology
 
Sexy React Stack
KMS Technology
 
Common design principles and design patterns in automation testing
KMS Technology
 
[Webinar] Test First, Fail Fast - Simplifying the Tester's Transition to DevOps
KMS Technology
 
KMSNext Roadmap
KMS Technology
 
KMS Introduction
KMS Technology
 
What's new in the Front-end development nowadays?
KMS Technology
 
JavaScript - No Longer A Toy Language
KMS Technology
 
JavaScript No longer A “toy” Language
KMS Technology
 
Preparations For A Successful Interview
KMS Technology
 
Introduction To Single Page Application
KMS Technology
 
AWS: Scaling With Elastic Beanstalk
KMS Technology
 
KMS Introduction
KMS Technology
 
Technology Application Development Trends For IT Students
KMS Technology
 
Contributors for Delivering a Successful Testing Project Seminar
KMS Technology
 
Increase Chances to Be Hired as Software Developers - 2014
KMS Technology
 
Software Technology Trends in 2013-2014
KMS Technology
 
Cross-platform Mobile Development with C# and Xamarin Webinar
KMS Technology
 
Software Testing Process & Trend
KMS Technology
 

Recently uploaded (20)

PDF
Tea4chat - another LLM Project by Kerem Atam
a0m0rajab1
 
PDF
Best ERP System for Manufacturing in India | Elite Mindz
Elite Mindz
 
PDF
BLW VOCATIONAL TRAINING SUMMER INTERNSHIP REPORT
codernjn73
 
PDF
A Day in the Life of Location Data - Turning Where into How.pdf
Precisely
 
PPTX
Comunidade Salesforce São Paulo - Desmistificando o Omnistudio (Vlocity)
Francisco Vieira Júnior
 
PDF
Chapter 1 Introduction to CV and IP Lecture Note.pdf
Getnet Tigabie Askale -(GM)
 
PDF
How-Cloud-Computing-Impacts-Businesses-in-2025-and-Beyond.pdf
Artjoker Software Development Company
 
PDF
Accelerating Oracle Database 23ai Troubleshooting with Oracle AHF Fleet Insig...
Sandesh Rao
 
PPTX
ChatGPT's Deck on The Enduring Legacy of Fax Machines
Greg Swan
 
PPT
Coupa-Kickoff-Meeting-Template presentai
annapureddyn
 
PPTX
The-Ethical-Hackers-Imperative-Safeguarding-the-Digital-Frontier.pptx
sujalchauhan1305
 
PPTX
OA presentation.pptx OA presentation.pptx
pateldhruv002338
 
PDF
CIFDAQ'S Market Insight: BTC to ETH money in motion
CIFDAQ
 
PDF
Google I/O Extended 2025 Baku - all ppts
HusseinMalikMammadli
 
PDF
Cloud-Migration-Best-Practices-A-Practical-Guide-to-AWS-Azure-and-Google-Clou...
Artjoker Software Development Company
 
PDF
Why Your AI & Cybersecurity Hiring Still Misses the Mark in 2025
Virtual Employee Pvt. Ltd.
 
PDF
How Open Source Changed My Career by abdelrahman ismail
a0m0rajab1
 
PDF
This slide provides an overview Technology
mineshkharadi333
 
PDF
NewMind AI Weekly Chronicles - July'25 - Week IV
NewMind AI
 
PDF
Automating ArcGIS Content Discovery with FME: A Real World Use Case
Safe Software
 
Tea4chat - another LLM Project by Kerem Atam
a0m0rajab1
 
Best ERP System for Manufacturing in India | Elite Mindz
Elite Mindz
 
BLW VOCATIONAL TRAINING SUMMER INTERNSHIP REPORT
codernjn73
 
A Day in the Life of Location Data - Turning Where into How.pdf
Precisely
 
Comunidade Salesforce São Paulo - Desmistificando o Omnistudio (Vlocity)
Francisco Vieira Júnior
 
Chapter 1 Introduction to CV and IP Lecture Note.pdf
Getnet Tigabie Askale -(GM)
 
How-Cloud-Computing-Impacts-Businesses-in-2025-and-Beyond.pdf
Artjoker Software Development Company
 
Accelerating Oracle Database 23ai Troubleshooting with Oracle AHF Fleet Insig...
Sandesh Rao
 
ChatGPT's Deck on The Enduring Legacy of Fax Machines
Greg Swan
 
Coupa-Kickoff-Meeting-Template presentai
annapureddyn
 
The-Ethical-Hackers-Imperative-Safeguarding-the-Digital-Frontier.pptx
sujalchauhan1305
 
OA presentation.pptx OA presentation.pptx
pateldhruv002338
 
CIFDAQ'S Market Insight: BTC to ETH money in motion
CIFDAQ
 
Google I/O Extended 2025 Baku - all ppts
HusseinMalikMammadli
 
Cloud-Migration-Best-Practices-A-Practical-Guide-to-AWS-Azure-and-Google-Clou...
Artjoker Software Development Company
 
Why Your AI & Cybersecurity Hiring Still Misses the Mark in 2025
Virtual Employee Pvt. Ltd.
 
How Open Source Changed My Career by abdelrahman ismail
a0m0rajab1
 
This slide provides an overview Technology
mineshkharadi333
 
NewMind AI Weekly Chronicles - July'25 - Week IV
NewMind AI
 
Automating ArcGIS Content Discovery with FME: A Real World Use Case
Safe Software
 

Behavior Driven Development and Automation Testing Using Cucumber

  • 1. BEHAVIOR-DRIVEN DEVELOPMENT (BDD) AND AUTOMATION TESTING WITH CUCUMBER November 2013 KMS Technology: http://kms-technology.com 1
  • 2. SAMPLE REQUIREMENT Feature: login to the system. As a user, I want to login into the system when I provide username and password. Scenario: login successfully Given the login page is opening When I input username into the username textbox And I input valid password into the password textbox And I click Login button Then I am on the Home page 2
  • 3. AUTOMATION TEST @Test public void fb_login_test() throws Exception { driver.get("https://www.facebook.com/"); driver.findElement(By.id("email")).clear(); driver.findElement(By.id("email")).sendKeys("[email protected]"); driver.findElement(By.id("pass")).clear(); driver.findElement(By.id("pass")).sendKeys("********"); driver.findElement(By.id("u_0_e")).click(); } 3
  • 5. AGENDA BDD and Agile Development Practice Automation Testing with Cucumber Developing Cucumber-Based Automation Framework BDD/Cucumber – Pros & Cons 5
  • 6. HOW WE ENGAGE, WHY WE ARE YOUR BEST PARTNER…. Bright Minds, Brilliant Solutions 6 BDD & AGILE DEVELOPMENT PRACTICE
  • 9. BDD AND AGILE DEVELOPMENT PRACTICE 9
  • 10. HOW WE ENGAGE, WHY WE ARE YOUR BEST PARTNER…. Bright Minds, Brilliant Solutions 10 AUTOMATION TESTING WITH CUCUMBER
  • 11. CUCUMBER APPROACH 11 Given /^I launch "([^"]*)" page$/ do |page| visit(page) End When /^I fill in "([^"]*)" with "([^"]*)"$/ do |field, value| fill_in field, :with => value end
  • 12. SCENARIO EXAMPLE IN BDD FORMAT Feature: login to the system. As a user, I want to login into the system when I provide username and password. @tag_login_email Scenario Outline: Verify that can login gmail Given I launch "https://accounts.google.com" page When I fill in “Email " with “<Email >" And I fill in “Passwd" with "<Password> " And I click on "signIn" button Then I am on the “Home” page Scenarios: | Email | Password | | [email protected] | kms@2013 | | [email protected] | kms@1234 | 12
  • 13. HOW CUCUMBER EXECUTE A SCENARIO 13
  • 15. TESTING AREA Web application Web services • Desktop application – http://pragprog.com/book/idgtr/scripted-gui-testing-with-ruby • Mobile application – http://www.moncefbelyamani.com/ios-automated-testing-with-calabash-cucumber-ruby/ 15
  • 16. CASE STUDY Complete 70% automation testing following agile process for a Healthcare Data Provider Client: – Health Market Science (HMS) Business Challenges: – 90% automation testing must be done for every 4- week sprint – Big Data Technology – Since MySQL, Oracle to NoSQL, Cassandra, Storm, Hadoop – Complicated test data creation 16
  • 17. INSTALLATION • Ruby: – Windows: http://rubyinstaller.org/ – Linux: https://rvm.io/rvm/install • Cucumber: • gem install cucumber http://rubygems.org/gems/cucumber 17
  • 18. DEMO • Web application: Cucumber + Capybara • Web Services: Cucumber + HTTParty + Savon 18
  • 19. DEMO: WEB APPLICATION 19 Cucumber Capybara Selenium WebDriver Poltergeist phantomjs
  • 21. 21 Navigating • (Object) visit(url) – The request method is always GET. – url (String) - The relative/absolute URL to navigate to. – Examples: • visit('http://google.com') DEMO: WEB APPLICATION
  • 22. 22 Navigating Action • (Object) click_link(locator, options = {}) – Finds a link by id or text and clicks it. • (Object) click_button(locator, options = {}) – Finds a button by id, text or value and clicks it. • (Object) fill_in(locator, options = {}) – Locate a text field or text area. The field can be found via its name, id or label text. DEMO: WEB APPLICATION
  • 23. 23 Navigating Action Check Point • (Boolean) has_content?(content) / • (Boolean) has_no_content?(content) – content (String) - The text to check for – Examples: • page.has_content?(‘hello’) • page.has_no_content?(‘hello’) DEMO: WEB APPLICATION
  • 24. 24 Navigating Action Check Point • RSpec magic matchers – page.should have_selector('table tr') – page.should have_no_selector(:content) – page.should have_css('table tr.foo') – page.should have_content('foo') DEMO: WEB APPLICATION
  • 26. Regular ExpressionRegular Expression Regular Expression DEMO: WEB APPLICATION
  • 27. HOW WE ENGAGE, WHY WE ARE YOUR BEST PARTNER…. Bright Minds, Brilliant Solutions 27 TAKE A REST
  • 28. DEMO • Web Services: Cucumber + HTTParty + Savon 28
  • 29. DEMO: WEB SERVICES 29 • At a glance: RESTful Web Service SOAP Web Service HTTParty/ RestClient /Json Savon Libs Cukes! GET/POST: Content: JSON {“data_id”:”1001”, “active”:”yes” “age”:”29”} GET/POST: Content: XML <SOAP:Env xlms… <data_id>1001</data_id> <active>yes</active> <age>29</age> </SOAP:Env>
  • 30. DEMO: WEB SERVICES HTTParty HTTParty.get 'http://myexample.com/newfeeds‘  Response.body={“id”:”100”,”Message”:”Hello”} HTTParty.post 'http://myexample.com/updateStatus', {:date => “Nov-11-2013”, :status => “Full of energy today”}  Response.body={“update”:”success”,”id”:”425”} HTTParty.put 'http://myexample.com/status/message’, {:timeout => 5000}  Response.body={“success”:”true”,”message”:”me ssage_1377057406713”} HTTParty.delete 'http://myexample.com/status/message_13770574067 14‘ => Response.body={“success”:”false”,”reason”:”non- exist”} 30 JSON ActualRslt = JSON.parse(response.body) Msg1 = ActualRslt[“message”] #= “Hello” ActualRslt = JSON.parse(response.body) Msg1 = ActualRslt[“update”] #= “success” ActualRslt = JSON.parse(response.body) Msg1 = ActualRslt[“message”] #= “message_1377057406713” ActualRslt = JSON.parse(response.body) Msg1 = ActualRslt[“success”] #= “false” Msg1 = ActualRslt[“reason”] #= “non-exist”
  • 31. DEMO: WEB SERVICES Savon # create a client for the service client = Savon.client(wsdl: 'http://service.example.com?wsdl') client.operations => [:find_user, :list_users] # call the 'findUser' operation response = client.call(:find_user, message: { id: 42 }) 31 actualRes = response.xml <?xml version="1.0" encoding="utf- 8"?><soap:Envelope....XMLSchema"> <soap:Body><findUserResponse xmlns="http://service.example.com"> <findUserResult><Success>true</Success> <LastName>Smith</LastName> <FirstName>John</FirstName> <City>Mountain View</City> <State>CA</State><WeatherID> </findUserResult></findUserResponse> </soap:Body></soap:Envelope>
  • 32. DEMO: WEB SERVICES Feature: Get Weather status to display on webpage As an owner of Traveling Service, I want to be able to get weather status of any location based on address of client's request Scenario Outline: Get weather status by address of client's requests Given The check IP location and weather web services are running When I send request to get location detail of address "<Address>" Then I should have ZIP code and "<Country>" of that location And I send request to get weather status of that location by its ZIP code Then I should receive current "Temperature, Wind, RelativeHumidity" and "<City_Name>" and "<State>" of that location Scenarios: |Address |Country |City_Name |State | |www.google.com |United States |Mountain View |California | 32
  • 33. HOW WE ENGAGE, WHY WE ARE YOUR BEST PARTNER…. Bright Minds, Brilliant Solutions 33 DEVELOPING CUCUMBER-BASED AUTOMATION FRAMEWORK
  • 34. DEVELOPING CUCUMBER-BASED AUTOMATION FRAMEWORK 34 Web Service UIDatabase Step Library & Object Definition Environment Configuration Web driver (IE,CH,FF) Cassandra MySQL Oracle RESTful WS SOAP WS Test Data Repo. Reports /Logs CORE LAYER Feature Repository Test Execution Tester A Tester B Tester C Tester D TRANSLATION LAYER DESCRIPTION LAYER Web Apps OCI8, Cassandra HTTParty Savon, JSON Openssl Capybara Xmlparser ……….
  • 35. DEVELOPING CUCUMBER-BASED AUTOMATION FRAMEWORK 35 Web Service UIDatabase Step Library & Object Definition Environment Configuration Web driver (IE,CH,FF) Cassandra MySQL Oracle RESTful WS SOAP WS Test Data Repo. Reports /Logs CORE LAYER Feature Repository Test Execution Tester A Tester B Tester C Tester D TRANSLATION LAYER DESCRIPTION LAYER Web Apps OCI8, Cassandra HTTParty Savon, JSON Openssl Capybara Xmlparser ……….
  • 36. DEVELOPING CUCUMBER-BASED AUTOMATION FRAMEWORK 36 Web Service UIDatabase Step Library & Object Definition Environment Configuration Web driver (IE,CH,FF) Cassandra MySQL Oracle RESTful WS SOAP WS Test Data Repo. Reports /Logs CORE LAYER Feature Repository Test Execution Tester A Tester B Tester C Tester D TRANSLATION LAYER DESCRIPTION LAYER Web Apps OCI8, Cassandra HTTParty Savon, JSON Openssl Capybara Xmlparser ……….
  • 37. DEVELOPING CUCUMBER-BASED AUTOMATION FRAMEWORK 37 Web Service UIDatabase Step Library & Object Definition Environment Configuration Web driver (IE,CH,FF) Cassandra MySQL Oracle RESTful WS SOAP WS Test Data Repo. Reports /Logs CORE LAYER Feature Repository Test Execution Tester A Tester B Tester C Tester D TRANSLATION LAYER DESCRIPTION LAYER Web Apps OCI8, Cassandra HTTParty Savon, JSON Openssl Capybara Xmlparser ……….
  • 38. DEVELOPING CUCUMBER-BASED AUTOMATION FRAMEWORK 38 Web Service UIDatabase Step Library & Object Definition Environment Configuration Web driver (IE,CH,FF) Cassandra MySQL Oracle RESTful WS SOAP WS Test Data Repo. Reports /Logs CORE LAYER Feature Repository Test Execution Tester A Tester B Tester C Tester D TRANSLATION LAYER DESCRIPTION LAYER Web Apps OCI8, Cassandra HTTParty Savon, JSON Openssl Capybara Xmlparser ……….
  • 39. 39 DEVELOPING CUCUMBER-BASED AUTOMATION FRAMEWORK A Hybrid Test Automation Framework Keyword-Driven Test Library Architecture Functional Decomposition Data-Driven Object Action Argument Login.txt_usr set myname Login.txt_pwd set mypass Login.btn_sign click Framework Method
  • 40. HOW WE ENGAGE, WHY WE ARE YOUR BEST PARTNER…. Bright Minds, Brilliant Solutions 40 BDD/CUCUMBER – PROS & CONS
  • 41. 41 BDD/CUCUMBER - PROS  BBD is FRIENDLY and UNDERSTANDABLE by non- technical User  Great support from RUBY community - Automation framework based BDD Cucumber is NOT REALLY HARD to develop and maintenance  Support on MULTIPLE PLATFORM, OS and different browsers
  • 42. 42 BDD/CUCUMBER - CONS  Incompatibility among GEM versions  Lacking of tool for managing Features and Scenarios effectively
  • 43. ARE YOUR BEST PARTNER…. Bright Minds, Brilliant Solutions 43 Q&A
  • 44. © 2013 KMS Technology THANK YOU 44
  • 45. REFERENCES 45 • All about BDD Cucumber: http://cukes.info/ • BDD cucumber book: http://www.amazon.com/The-Cucumber- Book-Behaviour-Driven-Development/dp/1934356808 • Ruby gems: http://rubygems.org • Ruby programming: http://www.ruby-lang.org