From: ale@... Date: 2001-01-27T07:46:44+09:00 Subject: [ruby-talk:9962] Re: RubyUnit - running all unit tests Hi Bil, > i.e., i have pairs of files like Element.rb/ElementUT.rb > and Interface.rb/InterfaceUT.rb. > each of the fooUT.rb files have a suite of testcases > inside of them -- each with testcase methods which begin > with "test", e.g., testNew, testFlux, etc. > question: how do i run all the testcases for all the fooUT.rb > files. is this somehow part of the testing framework? There's no tool, AFAIK, in RubyUnit for that. I guess there will be one some day. > right now i'm just using the foreach command in the shell, e.g., > $foreach f (*UT.rb) > > echo $f > > ruby $f > > end There's of course a Ruby way for the same thing. # Simple test runner which runs all test in separate interpreters. # Usage: ruby runit_all.rb [dir] [ruby] [unittest_re] # # Optional argument dir specifies directory where tests are collected. # Run like: runit_all.rb /home/foo/src/my_tests # Default value: . # Optional argument ruby specifies the path and name to the ruby # interpreter executed for each unit test file. # Default value: ruby # Optional argument unittest_re specifies the regular expression used # to filter the unit test files out from the other files. # Default value: /UT.rb$/ according to # (C) 2001 Aleksi Niemela dir = ARGV.shift || "." ruby = ARGV.shift || "ruby" unittest_re = ARGV.shift || Regexp.new(/\UT.rb$/) unittests = Dir[dir+"/*"].find_all {|fname| fname =~ unittest_re } unittests.each { |file| cmd = "#{ruby} #{file}"; %x{#{cmd}} } - Aleksi