Test on Rails ✘╹◡╹✘

089127ffb92a19d3d37815673cca06dc?s=47 r7kamura
September 19, 2012

Test on Rails ✘╹◡╹✘

089127ffb92a19d3d37815673cca06dc?s=128

r7kamura

September 19, 2012
Tweet

Transcript

  1. Test on Rails based on “Rails Test Prescriptions” by Noel

    Rappin Ryo Nakamura (@r7kamura) ✘ ╹◡╹ ✘
  2. 1. Why test? 2. Unit 3. Model 4. Functional 5.

    View 6. Integration
  3. Why test?

  4. * to speed up validation * to design architectures *

    to assure its quality ... Why test?
  5. to speed up validation automating test * open browser... *

    type the URL “h..tt..p://...” * check the contents...
  6. to design architecture * write clean and independent code (test

    behaves like a third-party code) * think the correct behavior of code (this would be an example of test)
  7. to assure its quality * prevent code from enbugging *

    maybe forced to write test ... ;(
  8. For more details why you... Please ask Mohicans around you

  9. Unit Test

  10. Forms of writing unit test - ✘╹◡╹ ✘ http://r7kamura.hatenablog.com/ entry/2012/09/19/113239

    Unit Test
  11. Model Test

  12. Unit Test of Model. It's easy to write Model Test.

    "Skinny Controller, Fat Model" Model Test
  13. Functional Test

  14. Functional tests Verify the system satisfies requested features of user.

    In Rails, it tests Controller & View by 1 request
  15. Targets 1. normal 2. invalid 3. security

  16. 1. normal A normal request should pass expected data to

    the view. @foo, sessions, cookies, flash
  17. 2. invalid An invalid request should be handled properly. redirect_to

    :root
  18. 3. security User’s and system’s security should be protected. get(others_entry_path).

    should_not be_success
  19. Non targets * many redirections * user interaction * HTTP

    methods (in Rails)
  20. View Test

  21. View Test Verify: * logic * structure (semantic mean) Used

    in Controller & Integration Test on Rails
  22. Good targets * logic in a view (necessary evil...;) *

    security problem * way to render structures
  23. Bad targets * text in HTML tag * look and

    feel verify only “semantic meanings”
  24. Integration Test

  25. Integration Test verify the interactions(I/F) of multiple components Acceptance test

    might see to this. Capybara, Cucumber, ...
  26. When to use Integration Test? To validate the interactions of

    the modules that are well-tested.
  27. Good targets * interactions in multiple steps * dependency with

    prev state * legacy code (black-box) * with JavaScript
  28. Bad targets * only 1 request * only for view

    testing
  29. 1. Why test? 2. Unit 3. Model 4. Functional 5.

    View 6. Integration
  30. thanks ✘ ╹◡╹ ✘ @r7kamura