Wes Gamble
2006-Jul-10 22:32 UTC
[Rails] Setup new data in the test database _after_ unit test runs
All, 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 -- Posted via http://www.ruby-forum.com/.
Wes Gamble
2006-Jul-10 22:36 UTC
[Rails] Re: Setup new data in the test database _after_ unit test ru
Wes Gamble wrote:> All, > > 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, > WesOr 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. WG -- Posted via http://www.ruby-forum.com/.
Ben Bleything
2006-Jul-10 22:41 UTC
[Rails] Setup new data in the test database _after_ unit test runs
On Tue, Jul 11, 2006, Wes Gamble wrote:> All, > > 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. Ben
Wes Gamble
2006-Jul-10 22:53 UTC
[Rails] Re: Setup new data in the test database _after_ unit test ru
Thanks, Ben, I figured it was a no-brainer. -- Posted via http://www.ruby-forum.com/.
Wes Gamble
2006-Jul-10 22:55 UTC
[Rails] Re: Setup new data in the test database _after_ unit test ru
Is there a way to specify the order in which the data is loaded so that FK constraints aren''t broken? -- Posted via http://www.ruby-forum.com/.
Ben Bleything
2006-Jul-10 22:58 UTC
[Rails] Re: Setup new data in the test database _after_ unit test ru
On Tue, Jul 11, 2006, Wes Gamble wrote:> 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 ;) Ben
Wes Gamble
2006-Jul-10 23:01 UTC
[Rails] Re: Setup new data in the test database _after_ unit test ru
Wes Gamble wrote:> Is there a way to specify the order in which the data is loaded so that > FK constraints aren''t broken?Because I wanted to use the existing data in my DB for my test data, I easily dumped it to YAML using the following: File.open(''filename'', "w") { |f| YAML.dump(ModelObject.find(:all), f)} -- Posted via http://www.ruby-forum.com/.
Wes Gamble
2006-Jul-11 03:52 UTC
[Rails] Re: Setup new data in the test database _after_ unit test ru
Wes Gamble wrote:> Wes Gamble wrote: >> Is there a way to specify the order in which the data is loaded so that >> FK constraints aren''t broken? > > Because I wanted to use the existing data in my DB for my test data, I > easily dumped it to YAML using the following: > > File.open(''filename'', "w") { |f| YAML.dump(ModelObject.find(:all), f)}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. Wes -- Posted via http://www.ruby-forum.com/.
Rob Sanheim
2006-Jul-11 15:48 UTC
[Rails] Re: Setup new data in the test database _after_ unit test ru
On 7/10/06, Wes Gamble <weyus@att.net> wrote:> Wes Gamble wrote: > > Wes Gamble wrote: > >> Is there a way to specify the order in which the data is loaded so that > >> FK constraints aren''t broken? > > > > Because I wanted to use the existing data in my DB for my test data, I > > easily dumped it to YAML using the following: > > > > File.open(''filename'', "w") { |f| YAML.dump(ModelObject.find(:all), f)} > > 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. - Rob -- http://www.robsanheim.com http://www.seekingalpha.com http://www.ajaxian.com
Maybe Matching Threads
- rake db:fixtures:load FIXTURES=xyz
- Verifying some understanding about manipulating DB data in before/after callbacks in RSpec
- Apache/fastcgi setup can''t find custom config/*.yml file!
- db:fixtures:load order
- class level "static" code in controller object not working