When running tests in Ruby's unit::test framework, is there a really easy way to specify, from the command-line, that only one test should be run (that is, specify the test class and test member variable)? If not, is there another framework that has this feature?
Asked
Active
Viewed 4,618 times
2 Answers
7
ruby /path/to/foo_test.rb --name test_should_do_something_really_spiffy
That will call the test defined by the method test_should_do_something_really_spiffy
in that file.
EDIT: That's for the Test::Unit
framework that most ruby tests are written with. I am assuming you meant the same.

Alex Wayne
- 178,991
- 47
- 309
- 337
-
Is "should_do_something_really_spiffy" a method of the subclass of test::unit? – Joe Soul-bringer Feb 12 '09 at 22:48
-
Yes. Note that Test::Unit is being phased out and replaced by "minitest" but it retains the same API. – Keltia Feb 12 '09 at 22:52
-
you can also use pattern as a --name argument and use -n switch for short; for example: -n /really_spiffy/ – Jakub Aug 13 '10 at 12:37
5
If you have the full Test::Unit
framework, you can do
ruby /path/to/foo_test.rb --help
to get the command line options. I don't think it works if you just have the minitest version though.

Andrew Grimm
- 78,473
- 57
- 200
- 338