« 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:
[...]
>> Depending on what you're changing, you may well want to restart Rails
>> each time to ensure that it's loading current code.
>
> That's what I'm trying to avoid.  That's what the load and reload!
> commands are hopefully doing.

I'll have to check on this, but I don't think that reload! reloads the
whole environment -- which is probably why you don't get the 10-second
wait.  You need to reload the environment to ensure that the code you're
testing is in a consistent state; otherwise, you might make changes to
your environment files that break your code, but you'd never know it.

>
>> 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
>
> I'm only running 1 test in the above example, "test_example1".  And I
> instantiate a new ExampleTest each time.  How could this lead to and old
> test influencing a new one?

If your old test has side effects (such as DB operations!) that are not
cleaned up, then it will influence the new test.  It's not just about
instantiating a new test object: to get good isolation you basically
have to have a pristine environment and DB, which is why autotest does
what it does.

I agree that reloading the environment can sometimes ve a bit slow.  But
you've got to do it if you want reliable tests.

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