O slideshow foi denunciado.
Utilizamos seu perfil e dados de atividades no LinkedIn para personalizar e exibir anúncios mais relevantes. Altere suas preferências de anúncios quando desejar.
BEHAVIOR-DRIVEN DEVELOPMENT (BDD)
AND AUTOMATION TESTING WITH CUCUMBER
November 2013
KMS Technology: http://kms-technology...
SAMPLE REQUIREMENT
Feature: login to the system.
As a user,
I want to login into the system when I provide username and
pa...
AUTOMATION TEST
@Test
public void fb_login_test() throws Exception {
driver.get("https://www.facebook.com/");
driver.findE...
HOW?
4
AGENDA
BDD and Agile Development Practice
Automation Testing with Cucumber
Developing Cucumber-Based Automation
Framewo...
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 "([^"]*)"...
SCENARIO EXAMPLE
IN BDD FORMAT
Feature: login to the system.
As a user, I want to login into the system when I provide use...
HOW CUCUMBER EXECUTE A
SCENARIO
13
SUMMARY
14
TESTING AREA
Web application
Web services
• Desktop application
– http://pragprog.com/book/idgtr/scripted-gui-testing-wi...
CASE STUDY
Complete 70% automation testing following
agile process for a Healthcare Data Provider
Client:
– Health Market...
INSTALLATION
• Ruby:
– Windows: http://rubyinstaller.org/
– Linux: https://rvm.io/rvm/install
• Cucumber:
• gem install cu...
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 navi...
22
Navigating
Action
• (Object) click_link(locator, options = {})
– Finds a link by id or text and clicks it.
• (Object) c...
23
Navigating
Action
Check Point
• (Boolean) has_content?(content) /
• (Boolean) has_no_content?(content)
– content (Strin...
24
Navigating
Action
Check Point
• RSpec magic matchers
– page.should have_selector('table tr')
– page.should have_no_sele...
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...
DEMO: WEB SERVICES
HTTParty
HTTParty.get 'http://myexample.com/newfeeds‘
 Response.body={“id”:”100”,”Message”:”Hello”}
HT...
DEMO: WEB SERVICES
Savon
# create a client for the service
client = Savon.client(wsdl:
'http://service.example.com?wsdl')
...
DEMO: WEB SERVICES
Feature: Get Weather status to display on webpage
As an owner of Traveling Service, I want to be able t...
HOW WE ENGAGE, WHY WE ARE YOUR
BEST PARTNER….
Bright Minds, Brilliant Solutions
33
DEVELOPING CUCUMBER-BASED
AUTOMATION FR...
DEVELOPING CUCUMBER-BASED
AUTOMATION FRAMEWORK
34
Web Service UIDatabase
Step Library & Object Definition
Environment Conf...
DEVELOPING CUCUMBER-BASED
AUTOMATION FRAMEWORK
35
Web Service UIDatabase
Step Library & Object Definition
Environment Conf...
DEVELOPING CUCUMBER-BASED
AUTOMATION FRAMEWORK
36
Web Service UIDatabase
Step Library & Object Definition
Environment Conf...
DEVELOPING CUCUMBER-BASED
AUTOMATION FRAMEWORK
37
Web Service UIDatabase
Step Library & Object Definition
Environment Conf...
DEVELOPING CUCUMBER-BASED
AUTOMATION FRAMEWORK
38
Web Service UIDatabase
Step Library & Object Definition
Environment Conf...
39
DEVELOPING CUCUMBER-BASED
AUTOMATION FRAMEWORK
A Hybrid Test Automation Framework
Keyword-Driven
Test Library
Architect...
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 - A...
42
BDD/CUCUMBER - CONS
 Incompatibility among GEM versions
 Lacking of tool for managing Features and
Scenarios effectiv...
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-B...
Terminou este documento.
Transfira e leia offline.
Próximos SlideShares
Behavior Driven Development with Cucumber
Avançar
Próximos SlideShares
Behavior Driven Development with Cucumber
Avançar
Transfira para ler offline e ver em ecrã inteiro.

Compartilhar

Behavior Driven Development and Automation Testing Using Cucumber

Baixar para ler offline

Behavior Driven Development and Automation Testing Using Cucumber

  1. 1. BEHAVIOR-DRIVEN DEVELOPMENT (BDD) AND AUTOMATION TESTING WITH CUCUMBER November 2013 KMS Technology: http://kms-technology.com 1
  2. 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. 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("bddtest@yahoo.com"); driver.findElement(By.id("pass")).clear(); driver.findElement(By.id("pass")).sendKeys("********"); driver.findElement(By.id("u_0_e")).click(); } 3
  4. 4. HOW? 4
  5. 5. AGENDA BDD and Agile Development Practice Automation Testing with Cucumber Developing Cucumber-Based Automation Framework BDD/Cucumber – Pros & Cons 5
  6. 6. HOW WE ENGAGE, WHY WE ARE YOUR BEST PARTNER…. Bright Minds, Brilliant Solutions 6 BDD & AGILE DEVELOPMENT PRACTICE
  7. 7. BEHAVIOR-DRIVEN DEVELOPMENT 7
  8. 8. GIVEN, WHEN, THEN 8
  9. 9. BDD AND AGILE DEVELOPMENT PRACTICE 9
  10. 10. HOW WE ENGAGE, WHY WE ARE YOUR BEST PARTNER…. Bright Minds, Brilliant Solutions 10 AUTOMATION TESTING WITH CUCUMBER
  11. 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. 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 | | kms.admin@gmail.com | kms@2013 | | kms.user@gmail.com | kms@1234 | 12
  13. 13. HOW CUCUMBER EXECUTE A SCENARIO 13
  14. 14. SUMMARY 14
  15. 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. 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. 17. INSTALLATION • Ruby: – Windows: http://rubyinstaller.org/ – Linux: https://rvm.io/rvm/install • Cucumber: • gem install cucumber http://rubygems.org/gems/cucumber 17
  18. 18. DEMO • Web application: Cucumber + Capybara • Web Services: Cucumber + HTTParty + Savon 18
  19. 19. DEMO: WEB APPLICATION 19 Cucumber Capybara Selenium WebDriver Poltergeist phantomjs
  20. 20. 20 DEMO: WEB APPLICATION
  21. 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. 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. 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. 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
  25. 25. DEMO: WEB APPLICATION
  26. 26. Regular ExpressionRegular Expression Regular Expression DEMO: WEB APPLICATION
  27. 27. HOW WE ENGAGE, WHY WE ARE YOUR BEST PARTNER…. Bright Minds, Brilliant Solutions 27 TAKE A REST
  28. 28. DEMO • Web Services: Cucumber + HTTParty + Savon 28
  29. 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. 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. 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. 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. 33. HOW WE ENGAGE, WHY WE ARE YOUR BEST PARTNER…. Bright Minds, Brilliant Solutions 33 DEVELOPING CUCUMBER-BASED AUTOMATION FRAMEWORK
  34. 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. 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. 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. 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. 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. 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. 40. HOW WE ENGAGE, WHY WE ARE YOUR BEST PARTNER…. Bright Minds, Brilliant Solutions 40 BDD/CUCUMBER – PROS & CONS
  41. 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. 42 BDD/CUCUMBER - CONS  Incompatibility among GEM versions  Lacking of tool for managing Features and Scenarios effectively
  43. 43. ARE YOUR BEST PARTNER…. Bright Minds, Brilliant Solutions 43 Q&A
  44. 44. © 2013 KMS Technology THANK YOU 44
  45. 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
  • KevinNguyen100

    Jan. 8, 2021
  • raja_5117

    Dec. 18, 2019
  • AngeloStimolo1

    Feb. 15, 2019
  • prasannagovindarajan

    Mar. 24, 2018
  • vinhomn

    Jun. 26, 2017
  • SahilMutreja

    Jun. 4, 2017
  • Igor_Terroso

    Apr. 17, 2017
  • ndesai3

    Feb. 28, 2017
  • MohanPrabhu16

    Feb. 1, 2017
  • AnilKulkarniCSM

    Apr. 15, 2016
  • biniosuaf

    Jan. 16, 2016
  • SanjayUpadhyay9

    Nov. 18, 2015
  • olli404

    Nov. 9, 2015
  • juminchoi

    Nov. 6, 2015
  • RiteshKumar294

    Oct. 18, 2015
  • YogeshShah13

    Oct. 9, 2015
  • alan_717

    Sep. 26, 2015
  • ctn2

    Aug. 12, 2015
  • studoo1

    Jul. 14, 2015
  • SamuelSanchez3

    May. 25, 2015

Vistos

Vistos totais

34.532

No Slideshare

0

De incorporações

0

Número de incorporações

78

Ações

Baixados

1.448

Compartilhados

0

Comentários

0

Curtir

35

×