CUCUMBER - Making BDD Fun

4,441 views

Published on

SQABD Lightning Talks 3
www.sqabd.com

Published in: Self Improvement, Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
4,441
On SlideShare
0
From Embeds
0
Number of Embeds
123
Actions
Shares
0
Downloads
121
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

CUCUMBER - Making BDD Fun

  1. 1. by<br />IntekhabSadekin<br />CUCUMBER –Making BDD Fun<br />
  2. 2. Question: One of main constituents of a salad?<br />Answer: SURE!!!<br />But that’s not what we are here for!!!<br />What is Cucumber? <br />
  3. 3. Behavior Driven Development and testing tool<br />Bunch of behaviors in the form of scenarios<br />Written mainly by non-technical people<br />Written in plain english<br />What is Cucumber actually?<br />
  4. 4. Write a behavior in the form of scenario in a feature file<br />Write the code in order to satisfy the scenario(the actual application and not the automation script)<br />Run the feature file<br />Watch it fail<br />Write the automation script with the template provided by cucumber<br />The behavior of the application is satisfied by the test script<br />What should you actually do?<br />
  5. 5. I am sorry but I am not going to discuss the merits and demerits of BDD<br />Behavior Driven Development? <br />
  6. 6. Project root/<br />Features<br />fileName1.feature<br />fileName2.feature<br />Support<br />Env.rb<br />Step_definitions<br />fileName1.rb<br />fileName2.rb<br />Directory structure<br />
  7. 7. Feature: Title<br />As a [role]<br />I want [feature]<br />So that [benefit]<br />Scenario: Title<br />Given [context]<br />When [event]<br />And [more event]<br />Then [outcome]<br />And [another outcome]<br />Lets get straight to it!!!<br />
  8. 8. What the @#$% !!!<br />
  9. 9. Feature: Login<br />As an admin<br />I want be able to login with my credentials<br />So that I get to the home page<br />Scenario: Able to successfully login<br />Given that I am on page “http://www.blahblah.com”<br />When I provide my username “admin”<br />And I provide my password “admin”<br />Then I should be at “HomePage”<br />Example<br />
  10. 10. Develop the application driven by the behavior described earlier in the feature file<br />Develop!!!<br />
  11. 11. $ cucumber login.feature<br />RUN the damn thing….<br />
  12. 12. Run and watch it fail…<br />
  13. 13. A template provided in order to write the automation script<br />
  14. 14. Given /^I am on &quot;([^&quot;]*)&quot;$/ do |url|<br />pending<br />end<br />When /^I enter username &quot;([^&quot;]*)&quot;$/ do |userName|<br />pending<br />end<br />When /^I enter password &quot;([^&quot;]*)&quot;$/ do |password|<br /> pending<br />end<br />When /^I click the button with name &quot;([^&quot;]*)&quot;$/ do |buttonValue|<br /> pending<br />end<br />Then /^I should be at &quot;([^&quot;]*)&quot;$/ do |url|<br /> pending<br />end<br />What should I do?<br />
  15. 15. They are called step definitions<br />Essentially bunch of ruby code<br />A library called Watir is used for the API<br />What was that? <br />
  16. 16. Run it again….<br />What next….<br />
  17. 17. Watch it fail again…<br />
  18. 18. Given /^I am on &quot;([^&quot;]*)&quot;$/ do |url|<br />@browser.goto(url)<br />end<br />When /^I enter username &quot;([^&quot;]*)&quot;$/ do |userName|<br /> pending<br />end<br />When /^I enter password &quot;([^&quot;]*)&quot;$/ do |password|<br /> pending<br />end<br />When /^I click the button with name &quot;([^&quot;]*)&quot;$/ do |buttonValue|<br /> pending<br />end<br />Then /^I should be at &quot;([^&quot;]*)&quot;$/ do |url|<br /> pending<br />end<br />Make the necessary changes<br />
  19. 19. Go back to step definitions and write the script in order to satisfy the behavior<br />
  20. 20. Keep on running the feature file until all of them turns green like a Cucumber<br />
  21. 21.
  22. 22. ?<br />Thank You!!!<br />

×