Rails Testing

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    Favorites, Groups & Events

    Rails Testing - Presentation Transcript

    1. Testing on Rails
    2. 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?
    3. Why Automate Tests?
      • We are programmers, right?
      • Computer's are great at performing mundane repeatable tasks.
      • Automated Regression Testing.
      • Refactoring is easier.
    4. 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.
    5. 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
    6. Unit Testing Models
      • Test Calculations
      • Test Validations
      • Test Callbacks
    7. Methods Available
      • assert boolean
      • assert_equal expected, actual
      • assert_raise *args
      • assert_instance_of klass, object
      • assert_nil object
      • assert_valid object
    8. 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)
    9. Functional Testing Controllers
      • Testing the Flow of the application
    10. 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
    11. Additional Methods Available
      • get
      • post
      • put
      • delete
      • head
      • assert_response
      • assert_template
      • assert_redirected_to
    12. 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 .
    13. Integration Testing
      • Testing Across Controllers
      • Testing User Stories
    14. Integration Methods
      • follow_redirect
      • xml_http_request
      • https
      • assert_difference
      • open_session
    15. Fixtures
      • YAML files
      • Dynamic Fixtures
      • Loading from Live Data
    16. 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
    SlideShare Zeitgeist 2009

    + mikeblakemikeblake Nominate

    custom

    243 views, 0 favs, 0 embeds more stats

    A look at Unit , Functional, and Integration testin more

    More info about this document

    © All Rights Reserved

    Go to text version

    • Total Views 243
      • 243 on SlideShare
      • 0 from embeds
    • Comments 0
    • Favorites 0
    • Downloads 0
    Most viewed embeds

    more

    All embeds

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?