The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
Testing Roundup

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
Jeremy Voorhis

Posts: 212
Nickname: jvoorhis
Registered: Oct, 2005

Jeremy Voorhis is a Rubyist in northeast Ohio.
Testing Roundup Posted: May 18, 2006 12:30 PM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by Jeremy Voorhis.
Original Post: Testing Roundup
Feed Title: JVoorhis
Feed URL: http://feeds.feedburner.com/jvoorhis
Feed Description: JVoorhis is a Rubyist in northeast Ohio. He rambles about Ruby on Rails, development practices, other frameworks such as Django, and on other days he is just full of snark.
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Jeremy Voorhis
Latest Posts From JVoorhis

Advertisement

This is just a brain dump with some of my recent thoughts about testing Rails applications.

Zed Shaw was recently interviewed on O’Reilly Net about his recent work with Mongrel. If you haven’t yet read that article, go ahead and read it now.

Zed talks about how he tests Mongrel’s performance, as well as fuzzing Mongrel. Later yesterday, Jason Watkins and I were discussing the feasibility of fuzzing a web application. Web applications have a huge parameter space, and though it may not be valuable to test every possible combination of input characters, it may be practical to test each input with data of varying size, ranging from zero to one and then increasing exponentially to a certain point.

It is also good to find boundary conditions for your server-side data as well. In a recent post, Obie Fernandez talks about the power of Ruby for generating data. It would be even more straightforward to generate a test data set between a couple of extreme boundaries to find out how your application fails with zero input, too many characters, junk characters, different encodings, etc.

Finally, I will leave you with an example of the format I have been using lately for functional tests. This code tests that the results are right for the wheel building resource of a very fictional, very high-tech bicycle factory. Similar tests which force errors and test boundary conditions would follow. The comments were added for clarity, but the whitespace would still be there.


def test_build_wheel_should_true_all_spokes
  # test-specific preconditions
  Wheel.available_spokes = 36

  # simulate request
  xhr :post, :build_wheel, :spokes => 36, :kind => 'mtb'

  # testing server-side data
  assert ! assigns( :wheel ).new_record?
  assert_equal 36, assigns( :wheel ).spokes.count
  assert assigns( :wheel ).spokes.all?{ &:trued? }

  # testing output
  assert_equal 'Your wheel has been built', flash[:messages]
  assert_response 200
  assert_response_content_type :js
end

Read: Testing Roundup

Topic: Ruby on Rails featured in Dr. Dobbs Previous Topic   Next Topic Topic: Stick it in Your ~/.irbrc: MethodFinder

Sponsored Links



Google
  Web Artima.com   

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