cucumber - making bdd fun
Post on 12-Nov-2014
4.511 Views
Preview:
DESCRIPTION
TRANSCRIPT
by
Intekhab Sadekin
CUCUMBER – 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 tool
Bunch of behaviors in the form of scenariosWritten mainly by non-technical peopleWritten in plain english
What is Cucumber actually?
Write a behavior in the form of scenario in a feature file
Write 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 script
What should you actually do?
I am sorry but I am not going to discuss
the merits and demerits of BDD
Behavior Driven Development?
Project root/Features
fileName1.featurefileName2.featureSupport
Env.rbStep_definitions
fileName1.rbfileName2.rb
Directory 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 page
Scenario: 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 file
Develop!!!
$ cucumber login.feature
RUN the damn thing….
Run and watch it fail…
A template provided in order to write the automation script
Given /^I am on "([^\"]*)"$/ do |url|
pending
end
When /^I enter username "([^\"]*)"$/ do |userName|
pending
end
When /^I enter password "([^\"]*)"$/ do |password|
pending
end
When /^I click the button with name "([^\"]*)"$/ do |buttonValue|
pending
end
Then /^I should be at "([^\"]*)"$/ do |url| pending
end
What should I do?
They are called step definitionsEssentially bunch of ruby codeA library called Watir is used for the API
What was that?
Run it again….
What next….
Watch it fail again…
Given /^I am on "([^\"]*)"$/ do |url|
@browser.goto(url)
end
When /^I enter username "([^\"]*)"$/ do |userName|
pending
end
When /^I enter password "([^\"]*)"$/ do |password|
pending
end
When /^I click the button with name "([^\"]*)"$/ do |buttonValue|
pending
end
Then /^I should be at "([^\"]*)"$/ do |url| pending
end
Make 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!!!
top related