On 6/28/07, Vassilis Rizopoulos <damphyr / freemail.gr> wrote:

> What would be a viable alternative for adding test data to an AR database?

Giles mentioned mocking which is certainly fine.

These posts might be helpful:
http://blog.floehopper.org/articles/2006/06/27/rails-fixtures-help-or-hindrance
http://blog.floehopper.org/articles/2006/08/10/fed-up-with-rails-fixtures-part-one
http://blog.floehopper.org/articles/2006/08/14/fed-up-with-rails-fixtures-part-two

In the context of Rails, I just do regular Model.create statements and
let the database cleanup after itself.  In stuff outside of rails, I
some kind of hacky stuff  that I can't really recommend. (Usually
manually blowing up DBs or calling destroy_all in cleanup)

I'd be interested in a safe way to do this too, although if you use
mocks, you may not need it at all.

Also, many of your tests won't require the data to be in the database.
 Sometimes just doing @my_record = Model.new and then testing methods
and things like that does the trick (so long as they don't need to be
saved to work).