cucumber - making bdd fun

22
by Intekhab Sadekin CUCUMBER – Making BDD Fun

Upload: sqabd

Post on 12-Nov-2014

4.511 views

Category:

Self Improvement


7 download

DESCRIPTION

SQABD Lightning Talks 3 www.sqabd.com

TRANSCRIPT

Page 1: CUCUMBER - Making BDD Fun

by

Intekhab Sadekin

CUCUMBER – Making BDD Fun

Page 2: 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?

Page 3: CUCUMBER - Making BDD Fun

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?

Page 4: CUCUMBER - Making BDD Fun

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?

Page 5: CUCUMBER - Making BDD Fun

I am sorry but I am not going to discuss

the merits and demerits of BDD

Behavior Driven Development?

Page 6: CUCUMBER - Making BDD Fun

Project root/Features

fileName1.featurefileName2.featureSupport

Env.rbStep_definitions

fileName1.rbfileName2.rb

Directory structure

Page 7: CUCUMBER - Making BDD Fun

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!!!

Page 8: CUCUMBER - Making BDD Fun

What the @#$% !!!

Page 9: CUCUMBER - Making BDD Fun

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

Page 10: CUCUMBER - Making BDD Fun

Develop the application driven by the behavior described earlier in the feature file

Develop!!!

Page 11: CUCUMBER - Making BDD Fun

$ cucumber login.feature

RUN the damn thing….

Page 12: CUCUMBER - Making BDD Fun

Run and watch it fail…

Page 13: CUCUMBER - Making BDD Fun

A template provided in order to write the automation script

Page 14: CUCUMBER - Making BDD Fun

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?

Page 15: CUCUMBER - Making BDD Fun

They are called step definitionsEssentially bunch of ruby codeA library called Watir is used for the API

What was that?

Page 16: CUCUMBER - Making BDD Fun

Run it again….

What next….

Page 17: CUCUMBER - Making BDD Fun

Watch it fail again…

Page 18: CUCUMBER - Making BDD Fun

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

Page 19: CUCUMBER - Making BDD Fun

Go back to step definitions and write the script in order to satisfy the behavior

Page 20: CUCUMBER - Making BDD Fun

Keep on running the feature file until all of

them turns green like a Cucumber

Page 21: CUCUMBER - Making BDD Fun
Page 22: CUCUMBER - Making BDD Fun

?Thank You!!!