List tests with test/unit

M

Matt Berney

Test::Unit is quite useful. I have a test class TC_BasicAcceptanceTest
with the following tests:

test_001_firstTest
test_002_secondTest
test_003_thirdTest

...

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
interest.

For example:

% ruby bat\bat.rb -l

TC_BasicAcceptanceTest
test_001_firstTest
test_002_secondTest
test_003_thirdTest

% 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 "#{tc.name}" }
exit
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top