• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Testing in Rails 3.x
 

Testing in Rails 3.x

on

  • 1,357 views

http://www.meetup.com/IsraelRubyUnderground/events/24126891/ ...

http://www.meetup.com/IsraelRubyUnderground/events/24126891/

The presentation was given in the last Israeli Ruby on Rails meetup. It gives a short overview for the latest testing technique in Rails 3.x.

Statistics

Views

Total Views
1,357
Views on SlideShare
1,350
Embed Views
7

Actions

Likes
0
Downloads
9
Comments
0

2 Embeds 7

http://www.hanrss.com 4
http://blog.rubyonrails.co.il 3

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

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

    Testing in Rails 3.x Testing in Rails 3.x Presentation Transcript

    • Test Automation with RoR for dummies
      Aug, 2011
      Eran Nelinger, SAP Labs
      eran.nelinger@sap.com
    • Why Test Automation
      Rails Testing Theory
      Deep dive into ‘Test’ directory
      Other automation investment tips
      8/22/2011
    • Why Test Automation
      Rails Testing Theory
      Deep dive into ‘Test’ directory
      Other automation investment tips
      8/22/2011
    • 8/22/2011
    • 8/22/2011
    • 8/22/2011
      Life’s too short for manual testing…
    • 8/22/2011
      • Rails make it super-easy for us to write tests (Almost everything we need is already in place with scaffolding)
      • Machine can better remember expected output
    • Why Test Automation
      Rails Testing Theory
      Deep dive into ‘Test’ directory
      Other automation investment tips
      8/22/2011
    • 8/22/2011
      • Rails applications typically interacts heavily with databases
      • If we would like to write efficient tests, they’ll need to interact with databases
    • 8/22/2011
      • We would like to be able to run our test in such environment where messing our data does not really make a difference
      • On the other hand we want to rebuild our data each time before a test run
    • 8/22/2011
      • The Three Environments approach allows us to set up and interact with test data without any danger of your tests altering data from your production environment
    • 8/22/2011
      test/fixtures:
      Just a fancy word for ‘sample-data’
      Populate our test-schema with content each time before a test runs
      Database independent
      Supports YAML as well as CSV
    • 8/22/2011
    • 8/22/2011
    • 8/22/2011
      test/unit:
      Unit-tests in rails are model-tests
      Logical assertions of our application’s business logic
      Should include at list one test method for every method in the model
    • 8/22/2011
      test/unit/helpers:
      Any method that might be used in more then one test-case
    • 8/22/2011
      test/unit/test_helper.rb:
      Define ActiveSupport::TestCase class which is the base class for each test (not only unit)
      Requires by each of the test files
      Switch to RAILS_ENV = “test”
      Brings us assertions from test test/unit
    • 8/22/2011
      test/functional
      ActionController::TestCase
      Controller specific tests
      • was the web request successful?
      • was the user redirected to the right page?
      • was the user successfully authenticated?
      • was the correct object stored in the response template?
      • was the appropriate message displayed to the user in the view?
    • 8/22/2011
      test/integration
      ActionController::IntegrationTest
      Interaction among number of controllers
      Generally used to test important flows
      Fixtures -> to be included explicitly
    • 8/22/2011
      test/performance
      ActionDispatch::PerformanceTest
      Runs a code profiler of each test method
      Flat and graph_html output is written by defauls
    • 8/22/2011
      Before running the tests:
      $ rake db:migrate
      runs any pending migrations on the development environment and updatesdb/schema.rb
      $ rake db:test:load
      recreates the test database from the current db/schema.rb
    • 8/22/2011
      • Assertions are the working bees of testing
      • Actually performs a check to see if expected==actual
    • 8/22/2011
      • Assertions are the working bees of testing
      • Actually performs a check to see if expected==actual
    • 8/22/2011
      • Rails specific assertions
    • Why Test Automation
      Rails Testing Theory
      Deep dive into ‘Test’ directory (Model testing)
      Other automation investment tips
      8/22/2011
    • 8/22/2011
    • 8/22/2011
    • 8/22/2011
    • 8/22/2011
    • 8/22/2011
    • 8/22/2011
    • 8/22/2011
    • 8/22/2011
    • 8/22/2011
    • 8/22/2011
    • 8/22/2011
    • 8/22/2011
    • 8/22/2011
    • Why Test Automation
      Rails Testing Theory
      Deep dive into ‘Test’ directory (Controller testing)
      Other automation investment tips
      8/22/2011
    • 8/22/2011
    • 8/22/2011
    • 8/22/2011
    • 8/22/2011
    • 8/22/2011
    • Why Test Automation
      Rails Testing Theory
      Deep dive into ‘Test’ directory (View testing)
      Other automation investment tips
      8/22/2011
    • 8/22/2011
    • 8/22/2011
    • 8/22/2011
    • 8/22/2011
    • 8/22/2011
    • 8/22/2011
    • 8/22/2011
    • 8/22/2011
    • 8/22/2011
    • 8/22/2011
      http://guides.rubyonrails.org/testing.html
      http://guides.rubyonrails.org/
      http://ruby-doc.org/stdlib/libdoc/test/unit/rdoc/classes/Test/Unit.html
      http://ruby-doc.org/stdlib/libdoc/test/unit/rdoc/classes/Test/Unit/Assertions.html
      http://api.rubyonrails.org/classes/ActiveSupport/TestCase.html
      http://api.rubyonrails.org/classes/ActionController/TestCase.html
      http://rdoc.info/github/rails/rails/master/ActionDispatch/IntegrationTest
      http://watir.com/
      http://pivotal.github.com/jasmine/
      http://railscasts.com/episodes/261-testing-javascript-with-jasmine
    • 8/22/2011