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