Rails Testing
Upcoming SlideShare
Loading in...5
×
 

Rails Testing

on

  • 1,338 views

A look at Unit , Functional, and Integration testing using the Rails Framework.

A look at Unit , Functional, and Integration testing using the Rails Framework.

Statistics

Views

Total Views
1,338
Views on SlideShare
1,338
Embed Views
0

Actions

Likes
0
Downloads
0
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as OpenOffice

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.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Rails Testing Rails Testing Presentation Transcript

    • Testing on Rails
    • Testing on Rails
      • Unit Tests
        • Models
      • Functional Tests
        • Controllers
        • Views
      • Integration Tests
        • Application
      • Fixtures
        • Data to support the Tests
        • Every Application get's tested, eventually.
      Why Test?
    • Why Automate Tests?
      • We are programmers, right?
      • Computer's are great at performing mundane repeatable tasks.
      • Automated Regression Testing.
      • Refactoring is easier.
    • Additional Benefits
        • Writing Tests makes better Programmers.
        • Automated Tests make better Applications.
      • Tests are a great warm-up / practice area.
          • With Unit Tests, “...you actually stand a chance of producing a product with close to zero defects.” -The Pragmatic Programmer
      • All the beautiful people write unit tests.
    • My Favorite Mistake
      • # Warning: The database defined as 'test' will be erased and
      • # re-generated from your development database when you run 'rake'.
      • # Do not set this db to the same as development or production.
      • test:
      • adapter: mysql
      • database: bathroom_attendant_test
      • username: root
      • password:
      • host: localhost
    • Unit Testing Models
      • Test Calculations
      • Test Validations
      • Test Callbacks
    • Methods Available
      • assert boolean
      • assert_equal expected, actual
      • assert_raise *args
      • assert_instance_of klass, object
      • assert_nil object
      • assert_valid object
    • Error vs. Failure
      • config
      • 1) Error:
      • test_truth(AttendantTest):
      • Mysql::Error: #28000Access denied for user 'root'@'localhost' (using password: NO)
      • 1) Failure:
      • test_truth(AttendantTest) [./test/unit/attendant_test.rb:8]:
      • <false> is not true.
      • 2) Error:
      • test_truth(QualificationTest):
      • NameError: undefined local variable or method `duh' for #<QualificationTest:0x2755958>
      • /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/test_process.rb:432:in `method_missing'
      • ./test/unit/qualification_test.rb:8:in `test_truth'
      • 4 tests, 3 assertions, 1 failures, 1 errors
      • rake aborted!
      • Command failed with status (1): [/usr/local/bin/ruby -Ilib:test &quot;/usr/local...]
      • (See full trace by running task with --trace)
    • Functional Testing Controllers
      • Testing the Flow of the application
    • The 4 Hashes of The Apocolypse
      • assigns : any objects that are stored as instance variables in actions for use in views
      • cookies : any objects cookies that are set
      • flash : any objects living in the flash
      • session : any object living in session variables
    • Additional Methods Available
      • get
      • post
      • put
      • delete
      • head
      • assert_response
      • assert_template
      • assert_redirected_to
    • Functional Testing Views
        • assert_select ( selector , *values, equality?, message?) { |elems| ... }
        • assert_select_rjs
        • assert_select_email
        • selector syntax is the same as
        • the syntax for CSS .
    • Integration Testing
      • Testing Across Controllers
      • Testing User Stories
    • Integration Methods
      • follow_redirect
      • xml_http_request
      • https
      • assert_difference
      • open_session
    • Fixtures
      • YAML files
      • Dynamic Fixtures
      • Loading from Live Data
    • Resources
        • Rails Manual
        • http://manuals.rubyonrails.com/read/chapter/28#page72
        • Integration Tests through 'script/console'
        • http://clarkware.com/cgi/blosxom/2006/04/04#HeadlessApp
        • Assertions Cheat Sheet
        • http://nubyonrails.topfunky.com/articles/2006/08/24/ruby-rails-test-rails-cheat-sheet
        • assert_select Cheat Sheet
        • http://blog.labnotes.org/2006/09/04/assert_select-cheat-sheet/
        • AWDR 2.0 Testing Chapter
        • http://media.pragprog.com/titles/rails2/Testing.pdf
        • SafetyNet Plugin
        • http://www.martinicity.net/articles/2007/02/07/safety-net
        • Difference between Mocks and Stubs
        • http://martinfowler.com/articles/mocksArentStubs.html