How about adding an option to re-run failed tests only

Hey guys! Hope you are doing great.

In the past couple of months, I’ve been doing some Phoenix development and really get used to the $ mix test --failed command, which as we all might guess, runs all failing tests for the previous run.

I searched for an equivalent command in rails but I wasn’t able to find it.

I know there are some plugins that help you to achieve a similar result but AFAIK there is built in feature like “run failed tests”.

The first question is, Am I right that such a feature does not exist?

The second question, (if I’m right with the first one) is something that worth doing?

Thanks!!

1 Like

Personally I use the re-run failed tests features that is available within IntelliJ IDEA. I guess the feature may be useful for those who don’t have such a feature in their IDE.

1 Like

You’re correct in that the command rails test does not provide this option. However, many ruby test frameworks do provide this functionality directly (i.e. in rspec: rspec --only-failures).

Hey @swhudson, yeah that’s true. Maybe that’s why there is no built-in option I guess…

I was thinking about spiking an implementation and trying to get it in. You know, a basic adapter that forwards calls to the underlying lib and provides an implementation for those libs that doesn’t have such options (like mini-test)

Would you say that’s something worth doing/proposing?

Thanks!

I don’t know that I’m qualified to tell you if this is a railsy enough idea or not. One argument you might hear when proposing this is that core rails code shouldn’t need to know about implementation details of optional libraries and frameworks, which you would have to add in order to support functionality that doesn’t already exist in libraries like minitest.

If it were me, I’d probably punt on this because trying to implement this to augment popular ruby test framework functionality sounds like a whole lot of work for something that you could just as easily achieve with a Makefile. If you’re passionate about solving this problem, make a proposal, the worst outcome is that it gets rejected, and you’ll probably learn a ton about rails either way.

Hey Scott, thanks for your feedback!

I never thought about this in terms of dependencies but I agree that the core team might raise concerns about having to know implementation details about optional libs.

I’m not scared about the work this feature might require, because, as you mentioned, the by-product of it will be tons of learning about Rails.

However, I think the Makefile makes more sense for now :slight_smile:

Thanks again!!