Test Automation with RoR for dummies<br />Aug, 2011<br />Eran Nelinger, SAP Labs<br />eran.nelinger@sap.com<br />
Why Test Automation<br />Rails Testing Theory<br />Deep dive into ‘Test’ directory<br />Other automation investment tips<b...
Why Test Automation<br />Rails Testing Theory<br />Deep dive into ‘Test’ directory<br />Other automation investment tips<b...
8/22/2011<br />
8/22/2011<br />
8/22/2011<br />Life’s too short for manual testing…<br />
8/22/2011<br /><ul><li>Rails make it super-easy for us to write tests (Almost everything we need is already in place with ...
Machine can better remember expected output</li></li></ul><li>Why Test Automation<br />Rails Testing Theory<br />Deep dive...
8/22/2011<br /><ul><li>Rails applications typically interacts heavily with databases
If we would like to write efficient tests, they’ll need to interact with databases</li></li></ul><li>8/22/2011<br /><ul><l...
On the other hand we want to rebuild our data each time before a test run</li></li></ul><li>8/22/2011<br /><ul><li>The Thr...
8/22/2011<br />
8/22/2011<br />
8/22/2011<br />test/unit:<br />Unit-tests in rails are model-tests<br />Logical assertions of our application’s business l...
8/22/2011<br />test/unit/helpers:<br />Any method that might be used in more then one test-case<br />
8/22/2011<br />test/unit/test_helper.rb:<br />Define ActiveSupport::TestCase class which is the base class for each test (...
8/22/2011<br />test/functional<br />ActionController::TestCase<br />Controller specific tests<br /><ul><li>was the web req...
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?</li></li></ul><li>8/22/2011<br />test/integration<br />Acti...
8/22/2011<br />test/performance<br />ActionDispatch::PerformanceTest<br />Runs a code profiler of each test method<br />Fl...
8/22/2011<br />Before running the tests:<br />$ rake db:migrate<br />	runs any pending migrations on the development envir...
8/22/2011<br /><ul><li>Assertions are the working bees of testing
Actually performs a check to see if expected==actual</li></li></ul><li>8/22/2011<br /><ul><li>Assertions are the working b...
Actually performs a check to see if expected==actual</li></li></ul><li>8/22/2011<br /><ul><li>Rails specific assertions</l...
8/22/2011<br />
8/22/2011<br />
8/22/2011<br />
8/22/2011<br />
8/22/2011<br />
8/22/2011<br />
8/22/2011<br />
8/22/2011<br />
8/22/2011<br />
8/22/2011<br />
8/22/2011<br />
8/22/2011<br />
8/22/2011<br />
Why Test Automation<br />Rails Testing Theory<br />Deep dive into ‘Test’ directory (Controller testing)<br />Other automat...
8/22/2011<br />
8/22/2011<br />
8/22/2011<br />
8/22/2011<br />
8/22/2011<br />
Why Test Automation<br />Rails Testing Theory<br />Deep dive into ‘Test’ directory (View testing)<br />Other automation in...
8/22/2011<br />
8/22/2011<br />
8/22/2011<br />
8/22/2011<br />
8/22/2011<br />
8/22/2011<br />
8/22/2011<br />
8/22/2011<br />
8/22/2011<br />
8/22/2011<br />http://guides.rubyonrails.org/testing.html<br />http://guides.rubyonrails.org/<br />http://ruby-doc.org/std...
Upcoming SlideShare
Loading in...5
×

Testing in Rails 3.x

1,100

Published on

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.

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
1,100
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
11
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Testing in Rails 3.x

  1. 1. Test Automation with RoR for dummies<br />Aug, 2011<br />Eran Nelinger, SAP Labs<br />eran.nelinger@sap.com<br />
  2. 2. Why Test Automation<br />Rails Testing Theory<br />Deep dive into ‘Test’ directory<br />Other automation investment tips<br />8/22/2011<br />
  3. 3. Why Test Automation<br />Rails Testing Theory<br />Deep dive into ‘Test’ directory<br />Other automation investment tips<br />8/22/2011<br />
  4. 4. 8/22/2011<br />
  5. 5. 8/22/2011<br />
  6. 6. 8/22/2011<br />Life’s too short for manual testing…<br />
  7. 7. 8/22/2011<br /><ul><li>Rails make it super-easy for us to write tests (Almost everything we need is already in place with scaffolding)
  8. 8. Machine can better remember expected output</li></li></ul><li>Why Test Automation<br />Rails Testing Theory<br />Deep dive into ‘Test’ directory<br />Other automation investment tips<br />8/22/2011<br />
  9. 9. 8/22/2011<br /><ul><li>Rails applications typically interacts heavily with databases
  10. 10. If we would like to write efficient tests, they’ll need to interact with databases</li></li></ul><li>8/22/2011<br /><ul><li>We would like to be able to run our test in such environment where messing our data does not really make a difference
  11. 11. On the other hand we want to rebuild our data each time before a test run</li></li></ul><li>8/22/2011<br /><ul><li>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</li></li></ul><li>8/22/2011<br />test/fixtures:<br />Just a fancy word for ‘sample-data’<br />Populate our test-schema with content each time before a test runs<br />Database independent<br /> Supports YAML as well as CSV<br />
  12. 12. 8/22/2011<br />
  13. 13. 8/22/2011<br />
  14. 14. 8/22/2011<br />test/unit:<br />Unit-tests in rails are model-tests<br />Logical assertions of our application’s business logic<br />Should include at list one test method for every method in the model<br />
  15. 15. 8/22/2011<br />test/unit/helpers:<br />Any method that might be used in more then one test-case<br />
  16. 16. 8/22/2011<br />test/unit/test_helper.rb:<br />Define ActiveSupport::TestCase class which is the base class for each test (not only unit)<br />Requires by each of the test files<br />Switch to RAILS_ENV = “test”<br />Brings us assertions from test test/unit<br />
  17. 17. 8/22/2011<br />test/functional<br />ActionController::TestCase<br />Controller specific tests<br /><ul><li>was the web request successful?
  18. 18. was the user redirected to the right page?
  19. 19. was the user successfully authenticated?
  20. 20. was the correct object stored in the response template?
  21. 21. was the appropriate message displayed to the user in the view?</li></li></ul><li>8/22/2011<br />test/integration<br />ActionController::IntegrationTest<br />Interaction among number of controllers<br />Generally used to test important flows<br />Fixtures -> to be included explicitly<br />
  22. 22. 8/22/2011<br />test/performance<br />ActionDispatch::PerformanceTest<br />Runs a code profiler of each test method<br />Flat and graph_html output is written by defauls<br />
  23. 23. 8/22/2011<br />Before running the tests:<br />$ rake db:migrate<br /> runs any pending migrations on the development environment and updatesdb/schema.rb<br />$ rake db:test:load<br /> recreates the test database from the current db/schema.rb<br />
  24. 24. 8/22/2011<br /><ul><li>Assertions are the working bees of testing
  25. 25. Actually performs a check to see if expected==actual</li></li></ul><li>8/22/2011<br /><ul><li>Assertions are the working bees of testing
  26. 26. Actually performs a check to see if expected==actual</li></li></ul><li>8/22/2011<br /><ul><li>Rails specific assertions</li></li></ul><li>Why Test Automation<br />Rails Testing Theory<br />Deep dive into ‘Test’ directory (Model testing)<br />Other automation investment tips<br />8/22/2011<br />
  27. 27. 8/22/2011<br />
  28. 28. 8/22/2011<br />
  29. 29. 8/22/2011<br />
  30. 30. 8/22/2011<br />
  31. 31. 8/22/2011<br />
  32. 32. 8/22/2011<br />
  33. 33. 8/22/2011<br />
  34. 34. 8/22/2011<br />
  35. 35. 8/22/2011<br />
  36. 36. 8/22/2011<br />
  37. 37. 8/22/2011<br />
  38. 38. 8/22/2011<br />
  39. 39. 8/22/2011<br />
  40. 40. Why Test Automation<br />Rails Testing Theory<br />Deep dive into ‘Test’ directory (Controller testing)<br />Other automation investment tips<br />8/22/2011<br />
  41. 41. 8/22/2011<br />
  42. 42. 8/22/2011<br />
  43. 43. 8/22/2011<br />
  44. 44. 8/22/2011<br />
  45. 45. 8/22/2011<br />
  46. 46. Why Test Automation<br />Rails Testing Theory<br />Deep dive into ‘Test’ directory (View testing)<br />Other automation investment tips<br />8/22/2011<br />
  47. 47. 8/22/2011<br />
  48. 48. 8/22/2011<br />
  49. 49. 8/22/2011<br />
  50. 50. 8/22/2011<br />
  51. 51. 8/22/2011<br />
  52. 52. 8/22/2011<br />
  53. 53. 8/22/2011<br />
  54. 54. 8/22/2011<br />
  55. 55. 8/22/2011<br />
  56. 56. 8/22/2011<br />http://guides.rubyonrails.org/testing.html<br />http://guides.rubyonrails.org/<br />http://ruby-doc.org/stdlib/libdoc/test/unit/rdoc/classes/Test/Unit.html<br />http://ruby-doc.org/stdlib/libdoc/test/unit/rdoc/classes/Test/Unit/Assertions.html<br />http://api.rubyonrails.org/classes/ActiveSupport/TestCase.html<br />http://api.rubyonrails.org/classes/ActionController/TestCase.html<br />http://rdoc.info/github/rails/rails/master/ActionDispatch/IntegrationTest<br />http://watir.com/<br />http://pivotal.github.com/jasmine/<br />http://railscasts.com/episodes/261-testing-javascript-with-jasmine<br />
  57. 57. 8/22/2011<br />
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×