# How to use many fixtures for one table?

**URL:** <https://www.ruby-forum.com/t/how-to-use-many-fixtures-for-one-table/105346>\
**Category:** Rails\
**Created:** [May 29, 2007, 4:50am UTC](https://www.ruby-forum.com/t/how-to-use-many-fixtures-for-one-table/105346 "2007-05-29T04:50:46Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![yananay](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/5daacb/32.png) [@yananay](https://www.ruby-forum.com/u/yananay)\
**Post date:** [May 29, 2007, 4:50am UTC](https://www.ruby-forum.com/t/how-to-use-many-fixtures-for-one-table/105346/1 "2007-05-29T04:50:46Z")

</div>

hi all,  
now i have a problem when do the functinal testing.  
assume i have a table named “customers”.

when i run the first test case, i need 20 records in the “customers”  
table.  
when i run the second test case, i need 200 records in the “customers”  
table.

so, if i only use one “customers.yml” fixtures, the first test case  
will cost much time.

then how to use many fixtures for one table?

appriciated for your help, thanks!

---

<div class="post-metadata">

**Author:** ![yananay](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/5daacb/32.png) [@yananay](https://www.ruby-forum.com/u/yananay)\
**Post date:** [May 29, 2007, 6:06am UTC](https://www.ruby-forum.com/t/how-to-use-many-fixtures-for-one-table/105346/2 "2007-05-29T06:06:45Z")

</div>

I am not all that happy with fixtures as they are at the DB level and  
not the model level. You need to get IDs right between files etc.

Have you tried just creating a different YML file in the fixtures  
directory, then splitting your tests into separate classes that  
reference the different fixtures?

I do not know if this will work, but I would expect it to.

Michael

---

<div class="post-metadata">

**Author:** ![yananay](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/5daacb/32.png) [@yananay](https://www.ruby-forum.com/u/yananay)\
**Post date:** [May 29, 2007, 5:46pm UTC](https://www.ruby-forum.com/t/how-to-use-many-fixtures-for-one-table/105346/3 "2007-05-29T17:46:52Z")

</div>

rake db:fixtures:load [FIXTURES=x,y,z]

On May 28, 10:50 pm, Yan R. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![yananay](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/5daacb/32.png) [@yananay](https://www.ruby-forum.com/u/yananay)\
**Post date:** [May 31, 2007, 6:55am UTC](https://www.ruby-forum.com/t/how-to-use-many-fixtures-for-one-table/105346/4 "2007-05-31T06:55:11Z")

</div>

Joon You wrote:

> rake db:fixtures:load [FIXTURES=x,y,z]
> 
> On May 28, 10:50 pm, Yan R. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

i think i cannt use “rake” command in my test class?
