Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ruby Test::Unit Command line options?

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?

like image 257
Joe Soul-bringer Avatar asked Feb 12 '09 21:02

Joe Soul-bringer


People also ask

How do I run a ruby test?

If your tests don't require any specific actions before start and you don't want to configure additional options, such as code coverage, you can run them by using the following options: Place the caret at the test class to run all tests in that class, or at the test method, and press Ctrl+Shift+F10 .

What is assert in Ruby?

assert(test, [failure_message]) Tests if test is true. msg may be a String or a Proc. If msg is a String, it will be used as the failure message. Otherwise, the result of calling msg will be used as the message if the assertion fails.

What are test cases in Ruby?

Tests for a particular unit of code are grouped together into a test case, which is a subclass of Test::Unit::TestCase. Assertions are gathered in tests, member functions for the test case whose names start with test_.


2 Answers

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.

like image 132
Alex Wayne Avatar answered Oct 15 '22 03:10

Alex Wayne


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.

like image 22
Andrew Grimm Avatar answered Oct 15 '22 03:10

Andrew Grimm