byIntekhabSadekinCUCUMBER –Making BDD Fun
Question: One of main constituents of a salad?Answer: SURE!!!But that’s not what we are here for!!!What is Cucumber?
Behavior Driven Development and testing toolBunch of behaviors in the form of scenariosWritten mainly by non-technical peopleWritten in plain englishWhat is Cucumber actually?
Write a behavior in the form of scenario in a feature fileWrite the code in order to satisfy the scenario(the actual application and not the automation script)Run the feature fileWatch it failWrite the automation script with the template provided by cucumberThe behavior of the application is satisfied by the test scriptWhat should you actually do?
I am sorry but I am not going to discuss the merits and demerits of BDDBehavior Driven Development?
Project root/FeaturesfileName1.featurefileName2.featureSupportEnv.rbStep_definitionsfileName1.rbfileName2.rbDirectory structure
Feature: TitleAs a [role]I want [feature]So that [benefit]Scenario: TitleGiven [context]When [event]And [more event]Then [outcome]And [another outcome]Lets get straight to it!!!
What the @#$% !!!
Feature: LoginAs an adminI want be able to login with my credentialsSo that I get to the home pageScenario: Able to successfully loginGiven that I am on page “http://www.blahblah.com”When I provide my username “admin”And I provide my password “admin”Then I should be at “HomePage”Example
Develop the application driven by the behavior described earlier in the feature fileDevelop!!!
$ cucumber login.featureRUN the damn thing….
Run and watch it fail…
A template provided in order to write the automation script
      Given /^I am on "([^\"]*)"$/ do |url|pendingendWhen /^I enter username "([^\"]*)"$/ do |userName|pendingendWhen /^I enter password "([^\"]*)"$/ do |password|   pendingendWhen /^I click the button with name "([^\"]*)"$/ do |buttonValue|  pendingendThen /^I should be at "([^\"]*)"$/ do |url| pendingendWhat should I do?
They are called step definitionsEssentially bunch of ruby codeA library called Watir is used for the APIWhat was that?
Run it again….What next….
Watch it fail again…
Given /^I am on "([^\"]*)"$/ do |url|@browser.goto(url)endWhen /^I enter username "([^\"]*)"$/ do |userName|   pendingendWhen /^I enter password "([^\"]*)"$/ do |password|   pendingendWhen /^I click the button with name "([^\"]*)"$/ do |buttonValue|  pendingendThen /^I should be at "([^\"]*)"$/ do |url| pendingendMake the necessary changes
Go back to step definitions and write the script in order to satisfy the behavior
Keep on running the feature file until all of them turns green like a Cucumber
?Thank You!!!

CUCUMBER - Making BDD Fun

  • 1.
  • 2.
    Question: One ofmain constituents of a salad?Answer: SURE!!!But that’s not what we are here for!!!What is Cucumber?
  • 3.
    Behavior Driven Developmentand testing toolBunch of behaviors in the form of scenariosWritten mainly by non-technical peopleWritten in plain englishWhat is Cucumber actually?
  • 4.
    Write a behaviorin the form of scenario in a feature fileWrite the code in order to satisfy the scenario(the actual application and not the automation script)Run the feature fileWatch it failWrite the automation script with the template provided by cucumberThe behavior of the application is satisfied by the test scriptWhat should you actually do?
  • 5.
    I am sorrybut I am not going to discuss the merits and demerits of BDDBehavior Driven Development?
  • 6.
  • 7.
    Feature: TitleAs a[role]I want [feature]So that [benefit]Scenario: TitleGiven [context]When [event]And [more event]Then [outcome]And [another outcome]Lets get straight to it!!!
  • 8.
  • 9.
    Feature: LoginAs anadminI want be able to login with my credentialsSo that I get to the home pageScenario: Able to successfully loginGiven that I am on page “http://www.blahblah.com”When I provide my username “admin”And I provide my password “admin”Then I should be at “HomePage”Example
  • 10.
    Develop the applicationdriven by the behavior described earlier in the feature fileDevelop!!!
  • 11.
    $ cucumber login.featureRUNthe damn thing….
  • 12.
    Run and watchit fail…
  • 13.
    A template providedin order to write the automation script
  • 14.
    Given /^I am on "([^\"]*)"$/ do |url|pendingendWhen /^I enter username "([^\"]*)"$/ do |userName|pendingendWhen /^I enter password "([^\"]*)"$/ do |password| pendingendWhen /^I click the button with name "([^\"]*)"$/ do |buttonValue| pendingendThen /^I should be at "([^\"]*)"$/ do |url| pendingendWhat should I do?
  • 15.
    They are calledstep definitionsEssentially bunch of ruby codeA library called Watir is used for the APIWhat was that?
  • 16.
  • 17.
  • 18.
    Given /^I amon "([^\"]*)"$/ do |url|@browser.goto(url)endWhen /^I enter username "([^\"]*)"$/ do |userName| pendingendWhen /^I enter password "([^\"]*)"$/ do |password| pendingendWhen /^I click the button with name "([^\"]*)"$/ do |buttonValue| pendingendThen /^I should be at "([^\"]*)"$/ do |url| pendingendMake the necessary changes
  • 19.
    Go back tostep definitions and write the script in order to satisfy the behavior
  • 20.
    Keep on runningthe feature file until all of them turns green like a Cucumber
  • 22.