Re: Testing without Fixtures (?)

Matt Jones
Mon, 09 Feb 2009 06:50:53 -0000

On Feb 6, 2:37 pm, jhearn <jhe...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:
> I''m writing unit tests for a rails app whose behavior depends on
the
> relationships of tens of thousands of items in a DB.  I need this data
> in the test DB for a lot of tests.  Storing this data as fixtures,
> keeping it in sync with the production DB, and waiting HOURS for the
> fixtures to load whenever the test suite is run are all untenable
> options.
>

This is the first red flag - test data shouldn''t need to "keep in
sync
with
the production DB"; that''s why it''s TEST DATA.

> Concerns:
> * This seems to be in violation of the Rails philosophy of "make right
> things easy and the wrong things hard."
>

This does sound hard, and I think it''s the wrong thing...

Even in cases where the production DB is large, there should be a way
to trim down
the data to get test fixtures. For example, I''ve been working recently
with some code
using zipcode distances; the production DB mapping zips to coordinates
is 50k+ records.
But my fixture only contains a few zips, that match the ones needed by
the rest of the
test data set. I''d advise a similar strategy for your data set.

--Matt Jones