Unit Tests Aren’t Enoughand your QA guy can’t regression test for you...
Will this test save you?
def test_create_new_widget post :create_widget assert_response :successend
With this code?
# view:<%= form_for :widget %> <%= submit_tag “Create” %><% end %>
# controller:def create; puts “doing nothing”; end
The Individual Pieces Work...
... but your application does not!
What do we do?
QA Guy!
Benefits
Would he find the bug from before?
What if the bug came from a refactoring?
YOU are ultimately responsible for your app
Let’s Automate
Hello, Selenium!
The Code
The API
Programmers still do the testing!
Hello, Cucumber!
QA Can Write This
Scenario: Searching on Google Given I am on the homepage When I fill in “q” with “cukes” And I press “Google Search” Then I should see “cukes.info”
Scenario: Searching on Google
Given I am on the homepage
When I fill in “q” with “cukes”
And I press “Google Search”
Then I should see “cukes.info”
The Output
Scenario: Searching on Google # features/google_search.feature:6 Given I am on the homepage # features/step_definitions/webrat_steps.rb:6 When I fill in "q" with "cukes" # features/step_definitions/webrat_steps.rb:29 And I press "Google Search" # features/step_definitions/webrat_steps.rb:17 Then I should see "cukes.info" # features/step_definitions/webrat_steps.rb:121
1 scenario (1 passed)4 steps (4 passed)0m10.206s
Webrathttp://gitrdoc.com/brynary/webrat/tree/master
Webrat Caveats
• Won’t detect elements hidden by a class
• Won’t click things that aren’t links or buttons (usually not a big deal)
Beyond Webrat
When /^I search for “([^”])”$/ do |s| When %Q|I fill in “q” with “#{s}”| And %Q|I press “Google Search”|end
Cucumber Structure
features/*.featurefeatures/step_definitions/*_steps.rbfeatures/support/*.rb
Cuke-Talkerhttp://github.com/trotter/cuke-talker
Commands
• Given, When, Then, And
• !
• define step
• run feature
• show history
• show step definitions
Resources
• http://cukes.info
• http://gitrdoc.com/brynary/webrat/tree/master
• http://github.com/trotter/cuke-talker
Credits
http://www.flickr.com/photos/jflinchbaugh/3967895188/http://www.flickr.com/photos/vizzzual-dot-com/2738586453/http://www.flickr.com/photos/frangipani_photograph/3137183488/http://www.flickr.com/photos/chrismoncus/1366654132/
Top Related