Forum: Ruby List tests with test/unit

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Matt B. (Guest)
on 2007-07-23 23:33
Test::Unit is quite useful.  I have a test class TC_BasicAcceptanceTest
with the following tests:



You get the picture.

Now, the ruby bat.rb -n <test name> is really useful.  It allows the
execution of a single test within the test case.  For running tests (and
debugging) on the command line, it would be useful to list all the tests
in the suite.  Then, one could use the -n flag to run the one of

For example:

% ruby bat\bat.rb -l


% ruby bat\bat.rb -n test_002_secondTest

Now the question...
If one wanted to modify the autorunner.rb, how would one iterate through
the tests in the test case?  This code only lists the TC name.  How does
one list the individual test cases?

o.on('-l', '--list', 'List the tests to run.'){
  @collector[self].tests.each { |tc| puts "#{}" }
Jason R. (Guest)
on 2007-07-23 23:54
(Received via mailing list)
I'm not sure what @collector has exactly, but this is what you can do
to fit with collector as needed)

test_methods = MyTestClass.instance_methods.grep(/^test_/)

if "tc" is an instance of the test class, then simply do:


This topic is locked and can not be replied to.