# Test Database Empty after "rake test"?

**URL:** <https://discuss.rubyonrails.org/t/test-database-empty-after-rake-test/53465>\
**Category:** rubyonrails-talk\
**Created:** [August 7, 2010, 12:13pm UTC](https://discuss.rubyonrails.org/t/test-database-empty-after-rake-test/53465 "2010-08-07T12:13:18Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![11155](https://avatars.discourse-cdn.com/v4/letter/1/d26b3c/32.png) [@11155](https://discuss.rubyonrails.org/u/11155)\
**Post date:** [August 7, 2010, 12:13pm UTC](https://discuss.rubyonrails.org/t/test-database-empty-after-rake-test/53465/1 "2010-08-07T12:13:18Z")

</div>

Hey,

can somebody tell me why my test database is always empty after I run "rake test" but not after I test single test files? My rake db:seed for the test database takes like 6 minutes and I don't really wanna reseed it every time I run "rake test". Is it possible to not let "rake test" truncate my database?

---

<div class="post-metadata">

**Author:** ![11155](https://avatars.discourse-cdn.com/v4/letter/1/d26b3c/32.png) [@11155](https://discuss.rubyonrails.org/u/11155)\
**Post date:** [August 7, 2010, 5:06pm UTC](https://discuss.rubyonrails.org/t/test-database-empty-after-rake-test/53465/2 "2010-08-07T17:06:16Z")

</div>

I googled and went through the test files. There's no hint or anything... no one?

---

<div class="post-metadata">

**Author:** ![11155](https://avatars.discourse-cdn.com/v4/letter/1/d26b3c/32.png) [@11155](https://discuss.rubyonrails.org/u/11155)\
**Post date:** [August 9, 2010, 2:27pm UTC](https://discuss.rubyonrails.org/t/test-database-empty-after-rake-test/53465/3 "2010-08-09T14:27:25Z")

</div>

Heinz Strunk wrote:

> Hey,
> 
> can somebody tell me why my test database is always empty after I run "rake test" but not after I test single test files? My rake db:seed for the test database takes like 6 minutes and I don't really wanna reseed it every time I run "rake test". Is it possible to not let "rake test" truncate my database?

This question comes up on the list from time to time. I'll give the same answer I always give: that's a really, really bad (and dangerous) idea. The point is that each test starts from a known state. You shouldn't need your whole seed data to run your tests -- just use factories to create what you need for each test.

Best,

---

<div class="post-metadata">

**Author:** ![11155](https://avatars.discourse-cdn.com/v4/letter/1/d26b3c/32.png) [@11155](https://discuss.rubyonrails.org/u/11155)\
**Post date:** [August 12, 2010, 9:41am UTC](https://discuss.rubyonrails.org/t/test-database-empty-after-rake-test/53465/4 "2010-08-12T09:41:13Z")

</div>

Yeah, you're right. Might switch to Factories instead. Don't really need 500 NPC when I can test all the stuff having 5-10 🙂
