The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
Where To Test What

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Amos King

Posts: 78
Nickname: adkron
Registered: Jan, 2007

Amos King is a Web Developer for the US Postal Service and for Ramped Media.
Where To Test What Posted: Nov 4, 2008 10:58 PM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by Amos King.
Original Post: Where To Test What
Feed Title: DirtyInformation
Feed URL: http://feeds.feedburner.com/Dirtyinformation
Feed Description: Information about Ruby/Rails/JRuby/WebDevelpoment/whatever.
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Amos King
Latest Posts From DirtyInformation

Advertisement

volt meter Testing is very important to all of us, but where should our tests go, and what should they test? When jumping into an existing Rails application you should run all the tests, and then start looking through them. Developers should have certain expectation of where certain things are tested, but many tests aren't where they should be. So where should they go in a Rails application?

Unit tests are designed for you models. This doesn't seem to be a problem for most applications. There is a well defined line here.

Functional tests are for testing controllers. This line is a little less defined. The interactions between the controller, the model, and the view trip people up. The biggest problems fall in testing the view, and retesting the model from the controller perspective.

Model tests are not functional test. When you test the path of a validation for instance. It has already been tested in the unit test so stop and delete the test. Think about what the controllers actual job is. Test one happy model, and one sad(failed validations) model, but don't retest every single model validation through the controller tests.

STOP. Don't test your view here. The occasional assert_tag or assert_no_tag isn't bad, but remember that isn't really testing the controller. Minimize what you are testing to the class under test. This way the view can change styles and all your functional tests are still only testing the controller itself.

Integration testing is where the views should jump into the action. The integration tests should drive the application through the view and assert the interactions and the correct information is presented to the user.

Shoulda is a great testing framework that will help guide where things should be tested. The should methods can be your guide to testing. Then find a great integration test framework like Webrat. Get all these in your application and start writing tests where they belong.

Read: Where To Test What

Topic: Legalize Freedom Previous Topic   Next Topic Topic: Presenting for Presenters

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use