I want to run automated unit tests as part of my build. I am building
to my test environment. Upon successful completion of all of my unit
tests, I would then like to load some data (using a fixture, I imagine)
into my test database that will act as fresh “system test” data for my
users to play with.
What is the best way to “load the standard system test/user acceptance
data” after I’ve successfully run through all of my automated tests?
I want to run automated unit tests as part of my build. I am building
to my test environment. Upon successful completion of all of my unit
tests, I would then like to load some data (using a fixture, I imagine)
into my test database that will act as fresh “system test” data for my
users to play with.
What is the best way to “load the standard system test/user acceptance
data” after I’ve successfully run through all of my automated tests?
Thanks,
Wes
Or should I just have a separate Rails environment for “system test” (as
opposed to unit test) and manage that data separately? Even if I did
that, I would still want an easy way to load/delete the system test data
set easily.
I want to run automated unit tests as part of my build. I am building
to my test environment. Upon successful completion of all of my unit
tests, I would then like to load some data (using a fixture, I imagine)
into my test database that will act as fresh “system test” data for my
users to play with.
What is the best way to “load the standard system test/user acceptance
data” after I’ve successfully run through all of my automated tests?
There is a rake task for this purpose. rake db:fixtures:load
You could either run that after your tests are done (and you do a purge)
or, alternately, structure your tests/fixtures so that when they finish
running, the data is still valid and interesting. For instance, you
might do destructive tests before constructive tests, so that once the
tests are finished, the test objects you created still exist.
Is there a way to specify the order in which the data is loaded so that
FK constraints aren’t broken?
I don’t know for sure. My gut tells me no, since I believe it just
loads everything into hashes and hash order is unpredictable. Other
people probably know better than I do; I primarily develop with MySQL so
it’s not a problem for me
It appears that just calling db:fixtures:load will load the fixture
files in alphanumeric order, so I may just prefix the files in such a
way that they will load in the correct order.
It appears that just calling db:fixtures:load will load the fixture
files in alphanumeric order, so I may just prefix the files in such a
way that they will load in the correct order.
There is usually a command to tell your db to ignore constraints - I
know you can switch the fk constraints on and off with mysql. So one
solution I’ve seen is a simple script that turns of fk constraints,
does all the data loading, then turns constraints back on.