On Tue, Jul 13, 2010 at 09:19, Marnen Laibow-Koser <[email protected]> wrote:
> Dave Aronson wrote:
>> On Mon, Jul 12, 2010 at 23:23, Marnen Laibow-Koser
>> <[email protected]> wrote:
>>> Fearless Fool wrote:
>>
>>>> But then how do I run unit tests while preserving my carefully preloaded
>>>> data?
>>>
>>> You don't. �Good test isolation *requires* clearing the database for
>>> every test.
>>
>> Good ideal to strive for... but not absolutely necessary all the time.
>
> Wrong!  If the test has any potential of touching the database, it is
> *absolutely necessary all the time* to reset the DB to a known state.
> Usuallythat means clearing it.

Ah, there's the key: "Usually".  So, the line is at least a smidgen
never-ward of always.  I'll grant you at least a few "nines" of
always-ness, but it's still not 100%.  Except by rounding.  :-)

*If* a given database (or table or set of tables) is absolutely
constant, so that it will not be added to or subtracted from during
the course of any test, only referenced, as seems to be the case in
FF's situation, then it is (IMVHO) sufficient to only clear-and-load
it at the start of the entire suite, rather than incur the penalties
of doing so on every test.  Perhaps that could even be enforced (at
least for the duration of the tests) with some triggers.

On the other claw, if there aren't a large number of tests, or he can
make do with a much smaller (i.e., faster to clear and load) database,
or the database clearing and loading can be done by a much faster
mechanism (such as pointing a symlink to a different set of files?),
the point may be moot....

-Dave

-- 
Specialization is for insects. | Professional: http://davearonson.com
-Robert Anson Heinlein         | Programming:  http://codosaur.us
-------------------------------+ Leadership:   http://dare2xl.com
Have Pun, Will Babble!  -me    | Et Cetera:    http://davearonson.net

-- 
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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to