Behavior Driven Development<br />with Cucumber<br />
Cucumber cycle<br />1: Describe behaviour in plain text<br />2: Write a step definition in Ruby<br />3: Run and watch it f...
Given-When-Then<br />Given<br />The purpose of givens is to put the system in a known state before the user (or external s...
Feature file<br />Story:1.1.0 As  a user I want to be able to login to WebCPI<br />As a InnerWorkings user/administrator <...
Steps file<br />Given /^the user types &quot;(.*)&quot; into the &quot;(.*)&quot; field$/ do |text, textbox|<br />     	$s...
Web apps in any language – use Cucumber with one of the following:<br />Webrat – Ruby acceptance testing for web applicati...
Upcoming SlideShare
Loading in …5
×

Behavior Driven Development

1,807 views
1,774 views

Published on

This is a slide deck I used at a Dublin Alt.net meetup.

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,807
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
19
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Behavior Driven Development

  1. 1. Behavior Driven Development<br />with Cucumber<br />
  2. 2. Cucumber cycle<br />1: Describe behaviour in plain text<br />2: Write a step definition in Ruby<br />3: Run and watch it fail<br />4. Write code to make the step pass<br />5. Run again and see the step pass<br />6. Repeat 2-5 until all green<br />
  3. 3. Given-When-Then<br />Given<br />The purpose of givens is to put the system in a known state before the user (or external system) starts interacting with the system (in the When steps)<br />When <br />The purpose of When steps is to describe the key action the user performs<br />Then<br />The purpose of Then steps is to observe outcomes<br />
  4. 4. Feature file<br />Story:1.1.0 As a user I want to be able to login to WebCPI<br />As a InnerWorkings user/administrator <br />I want to be able to login to the WebCPI<br />So that I can view all available functions / reports or links assigned to me <br />Scenario: 1.1.1 User that provides no credentials<br />Given the user opens &quot;WebCPI Home&quot; page <br />When the user types &quot;&quot; into the &quot;Your e-mail address&quot; field <br />And the user types &quot;&quot; into the &quot;Your password&quot; field <br />And the user clicks the &quot;Log in&quot; button <br />Then there should be a &quot;Validation&quot; label, with the text &quot;E-mail address field cannot be empty & Password field cannot be empty.&quot; <br />Scenario: 1.1.2 User that provide no username cannot login<br />Given the user opens &quot;WebCPI Home&quot; page <br />When the user types &quot;&quot; into the &quot;Your e-mail address&quot; field <br />And the user types &quot;blabla&quot; into the &quot;Your password&quot; field <br />And the user clicks the &quot;Log in&quot; button <br />Then there should be a &quot;Validation&quot; label, with the text &quot;E-mail address field cannot be empty&quot; <br />
  5. 5. Steps file<br />Given /^the user types &quot;(.*)&quot; into the &quot;(.*)&quot; field$/ do |text, textbox|<br /> $selenium.typefind_TEXTBOX_element(textbox), text)<br />End<br />When /^the user clicks (?:on|the) &quot;(.*)&quot; button$/ do |button|<br /> $selenium.clickfind_BUTTON_element(button)<br /> sleep 4<br />End<br />Then /^there should be (?:a|an) &quot;(.*)&quot; label, with the text &quot;(.*)&quot;$/ do |textlabel, text|<br /> $selenium.get_text(find_TEXTLABEL_element(textlabel)).should == text.gsub(/|| & /, &quot; &quot;)<br />end<br />
  6. 6.
  7. 7.
  8. 8. Web apps in any language – use Cucumber with one of the following:<br />Webrat – Ruby acceptance testing for web applications<br />Watir – Drives IE (Windows only)<br />FireWatir – Drives Firefox on Windows, OSX and GNU/Linux<br />SafariWatir – Drives Safari (OS X only)<br />ChromeWatir – Drives Google Chrome<br />Celerity – Drives a fast headless browser with Javascript support. Examples here<br />Selenium – Runs any browser (any OS)<br />Mechanize – Runs a headless browser (any OS)<br />

×