Functional testing - don't create schema each time


#1

Setting up the data for my rails server is non trivial, it includes
schema creation, seeding the database with seed data, running indexing
using ferret.

I want to write functional tests that use the seed data and indices.

However, each time I run the functional tests, the db schema gets
dropped and re-created. Is there a way to preserve existing schema
and not re-create it each time?

thanks


#2

Obelix wrote:

Setting up the data for my rails server is non trivial, it includes
schema creation, seeding the database with seed data, running indexing
using ferret.

I want to write functional tests that use the seed data and indices.

However, each time I run the functional tests, the db schema gets
dropped and re-created. Is there a way to preserve existing schema
and not re-create it each time?

Then it wouldn’t be a test.

You need to test by running each step in the setup for the test for the
subsequent step. Test seeding by asserting the DB is empty (or by
emptying your
fixtures out!), call the seed method, and assert the database is seeded.
Test
indexing by seeding the database, asserting ferret is unindexed, calling
the
indexer, and asserting ferret can find data. And so on.

Test isolation is very important, and ActiveRecord will fight
you to preserve it. AR will think that you have simply neglected to tear
down
some database detail, and will diligently tear it down for you!


Phlip
http://www.zeroplayer.com/


#3

Thanks.

I guess we disagree on what I want to test :).

It was a simple solution of creating my own rake tasks, instead of
using the pre-built rake tasks.