The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
Another recommendation for your test suite

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
Daniel Berger

Posts: 1383
Nickname: djberg96
Registered: Sep, 2004

Daniel Berger is a Ruby Programmer who also dabbles in C and Perl
Another recommendation for your test suite Posted: Aug 29, 2005 11:51 AM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by Daniel Berger.
Original Post: Another recommendation for your test suite
Feed Title: Testing 1,2,3...
Feed URL: http://djberg96.livejournal.com/data/rss
Feed Description: A blog on Ruby and other stuff.
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Daniel Berger
Latest Posts From Testing 1,2,3...

Advertisement
Make sure that when folks run your unit tests, they're running against the *local copy*. Otherwise, you're either testing against an already installed version or you're forcing your users to install *before* they test, which is not what you want.

Here's a little something I stick at the top of my test suites:
# tc_foo.rb
base = File.basename(Dir.pwd)
if base == "test" || base =~ /foo/
   Dir.chdir ".." if base == "test"
   $LOAD_PATH.unshift(Dir.pwd + "/lib")
   Dir.chdir("test") rescue nil
end
...
require "foo"
require "test/unit"

So, assuming we're in the foo-1.0.0 directory, we can run the test suite as either "ruby test/tc_foo.rb", or cd to the "test" directory first and run "ruby tc_foo.rb" from there. In either case, it will attempt to use the version of the foo library in the current package, not one that may already be installed.

This is also why I always include a VERSION test. It's another way to make sure I'm testing against the version I'm expecting, and not an already installed version of the library.

Read: Another recommendation for your test suite

Topic: EU says no, nein, nej, non to software patents Previous Topic   Next Topic Topic: New Stuff

Sponsored Links



Google
  Web Artima.com   

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