Search code examples
ruby-on-railsrubytestingshoulda

Print a List of All Tests in a Rails App


Is there an easy ruby or rails command to get a list of all the tests in an application? I use Shoulda primarily, but if there's a ruby solution regardless of test suite that would work too.


Solution

  • I have found a roundabout solution: the test_benchmarker plugin. You run your tests with an extra environment variable like so:

    rake test BENCHMARK_TESTS=true
    

    You're best off piping the output to a file, because it will be long. But it will give you a list of all the test classes and tests themselves, for both unit and functional. Obviously it gives you the benchmarking results too, which is a bonus.

    Is there anything better? I guess this is pretty close, and the extra effort is so little, why NOT get the benchmark results too? RSpec has this feature built in, but maybe it'd be fun to write a version for Test::Unit.