How to print test names when executing Ruby Test::Unit tests

When I run my test_all.rb from the command line, I get ‘.’ when a test passes, but I don’t know which test it was that passed. I only get the names of tests that fail or error. Quite sensible – for regression testing, this is all you need. But where audit trails are required, I need to be able to provide a list of all tests that were executed in a particular test run. Here’s how to do it (using tests in a NetBeans project as an example)…

Instead of running:

ruby -I test -I lib test/test_all.rb

…run:

ruby -I test -I lib test/test_all.rb -v

The ‘verbose’ argument does exactly what I need! Here’s the kind of output you get:

test_that_passes(RelevantTestCaseClass): .
test_that_fails(RelevantTestCaseClass): F
test_that_errors(RelevantTestCaseClass): E

You’ll still get all the errors listed at the end of the run as usual.