Is it possible to run a single test in MiniTest?

I can run all tests in a single file with:

rake test TEST=path/to/test_file.rb

However, if I want to run just one test in that file, how would I do it?

I'm looking for similar functionality to:

rspec path/to/test_file.rb -l 25

The command should be:

% rake test TEST=test/test_foobar.rb TESTOPTS="--name=test_foobar1 -v"

Have you tried:

ruby path/to/test_file.rb --name test_method_name

No gem required: ruby -Itest test/lib/test.rb --name /some_test/

Source: http://blog.arvidandersson.se/2012/03/28/minimalicous-testing-in-ruby-1-9


This is one of the things that bother me about the string name definition in tests.

When you have:

def test_my_test
end

you always know how your test is named so you can execute it like this:

ruby my_test -n test_my_test

But when you have something like:

it "my test" do
end

you are never sure how this test is really named internally so you can not use the -n option just directly.

To know how this test is named internally you only have an option: execute the whole file to try to figure out looking in the logs.

My workaround is (temporally) add something to the test name very unique like:

it "my test xxx" do
end

and then use the RegEx version of the '-n' parameter like:

ruby my_test.rb -n /xxx/

I'm looking for similar functionality to rspec path/to/file.rb -l 25

With Nick Quaranto's "m" gem, you can say:

m spec/my_spec.rb:25