« Return to Thread: running a unit test over and over in script/console

Re: running a unit test over and over in script/console

by Adam Akhtar-2 :: Rate this Message:

Reply to Author | View in Thread


Andrew Arrow wrote:
> I started doing this:
>
> $ RAILS_ENV=test script/console
>
>>> load 'test/unit/models/example_test.rb'; r = Test::Unit::TestResult.new; reload!; ExampleTest.new(:test_example1).run(r) { |c,v| }; pp results
>
> and then just hit up arrow and run that same line again over and over in
> script/console.  

If you're going to do that, then it's probably better to declare a
function that will do all that so you don't have to rely on the up-arrow
key.  But why not just use autotest?

> That way I can make changes to the test and app code,
> and don't have to wait for rails startup each time.

Depending on what you're changing, you may well want to restart Rails
each time to ensure that it's loading current code.

>
> Does that make sense to others?  I'm a missing something that will make
> this a bad way to run a test?

Well, you may not be getting good test isolation -- there's the
potential for old test runs to influence new ones.  And it's more work
than it has to be -- autotest will do the same thing without you even
needing to press a key.  What's more, it will test a subset of the code
first to save time.  I guess I just don't see why not use autotest.

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
marnen@...
--
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@...
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

 « Return to Thread: running a unit test over and over in script/console