• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Unit Tests Aren't Enough

Unit Tests Aren't Enough



Covers integration testing with selenium and cucumber.

Covers integration testing with selenium and cucumber.



Total Views
Views on SlideShare
Embed Views



1 Embed 1

http://trotter.posterous.com 1


Upload Details

Uploaded via as Apple Keynote

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
Post Comment
Edit your comment
  • It won’t because the test code was testing create_widget, not create
  • Offload the work to someone else. He behaves like a user and finds problems the user would find.
  • He certainly would
  • Probably not, the QA guy typically only checks new features and will do a regression test every month or so.
  • Came out of work at Thoughtworks. Works on all platforms with all browsers and a ton of languages have clients
  • Is your QA guy going to learn a full on programming language?
  • There’s a lot here and your QA guy isn’t going to learn it all
  • This doesn’t seem too good. We’d much rather have QA / business involved (and hopefully even doing the work).
  • Scenario tells what we’re testing
  • Given sets up assumptions about your Scenario
  • When performs actions
  • And duplicates whatever came before
  • Then is your assertion
  • And let’s see this run in cucumber
  • 90% of what you do is click a link, fill in text, and assert that text is present. Webrat handles these for you.
  • Add your own step definitions in features/step_definitions/*.rb. <br /> There are some step_definitions your QA guy can&#x2019;t implement and you&#x2019;ll have to help.
  • Features go at the top level. <br /> Steps definitions go in step_definitions. <br /> Support files go in support. <br /> Cucumber will load everything.
  • Writing cucumber features can be time consuming. Cuke-talker is a command line IDE for writing them.
  • cuke-talker isn&#x2019;t even close to done. We&#x2019;re looking for help (yay open source!)
  • Given, When, Then, And behave just like they do in cucumber <br /> ! lets you execute arbitrary ruby <br /> define step opens a subrepel for defining a step <br /> feature will run a feature file from your features dir (will soon be run feature) <br /> show history shows all your previous Given, When, Then, Ands <br /> show step definitions shows all the steps you&#x2019;ve defined
  • Yay Pictures!

Unit Tests Aren't Enough Unit Tests Aren't Enough Presentation Transcript

  • Unit Tests Aren’t Enough and your QA guy can’t regression test for you...
  • Will this test save you? def test_create_new_widget post :create_widget assert_response :success end
  • 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
  • Webrat http://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/*.feature features/step_definitions/*_steps.rb features/support/*.rb
  • Cuke-Talker http://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/