-
Notifications
You must be signed in to change notification settings - Fork 88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to rerun single failing test by name #133
Comments
I think you can pass it through Minitest's environment variable Maybe it's enough if you type in in the console: ENV['TESTOPTS'] = '--name test_name' And then just save the file with the test name? |
I've tried your approach but with no luck. I'm not sure if I do this the right way.
But then I just get:
as an output and nothing else. |
Yes - nothing will happen, because that line just sets the environment variable guard's process. You need to MODIFY the file, so guard picks up the change and runs minitest - minitest should then check the environment variable - and run only the test matching the name. It's as if on an ordinary commandline you ran: TESTOPTS="-n test_name" ruby -Ilib:test test/path/to/my_controller.rb The problem with the above workaround is (if it works): you have to clear the ENV every time to run all the tests. In RSpec, you can just tell rspec which tests to run/skip by using the "focus" feature. Since there's no such thing in Minitest (as far as I know), probably the best option is to set and clear the environment variable. Simply put, Minitest doesn't have a runner like RSpec does - so it's hard to tell guard to tell guard-minitest to use a special option when you want it to. Instead, you may use the guard :minitest, cli: '--name test_name' do
# ...
end and Guard should restart when you change the file anyway. Hope that helps. |
You can also probably just add the Pry command yourself, by adding Ruby code to your Here's what a Pry plugin looks like for the https://github.com/guard/guard/blob/master/lib/guard/commands/change.rb Here's more about the currently supported commands: https://github.com/guard/guard/wiki/Interacting-with-Guard |
Also, the easiest way is to just probably copy the just test you want being run to a new file. |
Thanks for your assistance. I see that (probably) easiest way to do what I want is to switch from minitest to RSpec (where it is built in functionality). That's a pity because I really like minitest syntax :( |
Is it possible to re-run single test directly from Guard console?
I know I can do this from command line with:
but it would be really handy if I could just type something into Guard console e.g.
or something like that.
The text was updated successfully, but these errors were encountered: