One problem with this is that if you have suite_foo/test_a.rb and suite_bar/test_a.rb, the second test won't be run. A quick fix would be to use "load" instead of "require".

But better would be to use more of the pathname with require. Here's how i'd do it:

  TOPDIR = File.join(File.dirname(__FILE__), '..')
  $LOAD_PATH.unshift TOPDIR
  tests = Dir["suite*/*.rb"]
  tests.each {|t| require t}

(I'd put the "require 'test/unit'" in the individual tests instead so that they could also run singly.)

Bret

On 1/30/06, Chris McMahon <[EMAIL PROTECTED]> wrote:
Hi...

I have some tests in directories that share common code like

suite_foo/
     test_1.rb
     test_2.rb
suite_bar/
     test_3.rb
     test_4.rb
common/
     my_library.rb

My test runner script dips into each directory and then back out:

##############################################
TOPDIR = File.join(File.dirname(__FILE__), '..')
$LOAD_PATH.unshift TOPDIR
require 'test/unit'

test_dirs = Dir.glob("suite*")
test_dirs.each do |dir|
Dir.chdir(dir)

test_cases = Dir.glob("*rb")

test_cases.each {|f| require f }

Dir.chdir("..")

end #do
###########################################################

is this a reasonable approach?  It seems kinda thrashy to me, I wonder
if there's a better way to go about this.

-Chris

_______________________________________________
Wtr-general mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-general

_______________________________________________
Wtr-general mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-general

Reply via email to