views:

310

answers:

4

Same question as waloeiii in twitter:

How can I have autospec/test not run the full test suite after everything goes green? The next test I write will be red!

I'd rather run the full test suite manually.

By the way, I tried adding a failing spec:

it "should flunk" do
  flunk
end

but autospec seems to ignore it when it feels like it.

A: 

I think that this is by design - if you fix a failing spec, and all other specs in the section are green, then autospec will rerun the entire suite - this will tell you if the fix you applied to one area of your project has b0rked another or not.

If you just want to run the specs you are working on at any one time, then you can do it from the command line:

ruby spec/controllers/my_spec.rb

or from within Textmate by pressing cmd+r from your spec file. You should rerun your entire suite as you go anyway, otherwise you might be missing failing specs.

Mr. Matt
+1  A: 

Are you sure you are not confused about the intended behaviour of autotest's heuristics?

My understanding is that it runs tests for what has changed and will keep running failed tests until they pass and then once they pass it runs the whole test suite to make sure nothing else broke.

In effect it is being conservative and making sure you haven't introduced side effects that break other unrelated tests which is probably a good thing. The problem of course is that if you are doing fast red - green cycles you are going to be running your full suite a lot.

If you want to change these behaviours you need to edit the heuristics in the rails_autotest.rb file for zentest.

srboisvert
Thanks for pointing out e rails_autotest.rb. I'll look into it. By the way, even if I add a fake failing test (see above), autospec still sometimes reruns the entire test suite.
gsmendoza
I ended up disabling the said behavior in ZenTest-4.0.0/lib/autotest.rb. Thanks for the advice!
gsmendoza
A: 

You can use the following option to avoid this behavior -

autospec --no-full-after-failed
dzello
Hi Josh. I'm using ZenTest 4.3.1 and rspec 1.2.9. Even with --no-full-after-failed, when I pass a failing spec, autotest reruns the whole test suite.
gsmendoza
A: 

Bit late but I was looking for this as well so thought I'd post my solution:

Add the following to ~/.autotest:

class Autotest
  def rerun_all_tests
  end
end
PhilT
Hah! Will definitely try this out :)
gsmendoza