# About test database

**URL:** <https://www.ruby-forum.com/t/about-test-database/152158>\
**Category:** Rails\
**Created:** [October 30, 2008, 5:38pm UTC](https://www.ruby-forum.com/t/about-test-database/152158 "2008-10-30T17:38:11Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![daociyiyou](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/0ea827/32.png) [@daociyiyou](https://www.ruby-forum.com/u/daociyiyou)\
**Post date:** [October 30, 2008, 5:38pm UTC](https://www.ruby-forum.com/t/about-test-database/152158/1 "2008-10-30T17:38:11Z")

</div>

i have a conclusion to make sure,that is : when testing codes, only  
the fixtures data are stored in the test database table after running  
the test and the model saved during runing test method is not stored  
in the test database table? For example:  
#########  
def test\_save  
user=User.new(…)  
user.save  
end  
##########  
After running the test method,the user is not stored in the test  
database table?  
right?

---

<div class="post-metadata">

**Author:** ![daociyiyou](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/0ea827/32.png) [@daociyiyou](https://www.ruby-forum.com/u/daociyiyou)\
**Post date:** [October 30, 2008, 6:09pm UTC](https://www.ruby-forum.com/t/about-test-database/152158/2 "2008-10-30T18:09:55Z")

</div>

On 30 Oct 2008, at 16:37, daociyiyou wrote:

> ##########  
> After running the test method,the user is not stored in the test  
> database table?  
> right?

Sort of. It is stored in the test database, but the entire test runs  
within a transaction, which is rolled back at the end of the test.

Fred

---

<div class="post-metadata">

**Author:** ![daociyiyou](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/0ea827/32.png) [@daociyiyou](https://www.ruby-forum.com/u/daociyiyou)\
**Post date:** [October 31, 2008, 3:10am UTC](https://www.ruby-forum.com/t/about-test-database/152158/3 "2008-10-31T03:10:01Z")

</div>

> Sort of. It is stored in the test database, but the entire test runs  
> within a transaction, which is rolled back at the end of the test.
> 
> Fred

But rolled back at the end of this test method or the entire  
controller test? You means I need not consider if the user is saved in  
the test database table in the following test methods because the user  
is not in the database at that time?  
If the user is still in the database in the following test methods.i  
need to consider it because of my application’s logic.

---

<div class="post-metadata">

**Author:** ![daociyiyou](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/0ea827/32.png) [@daociyiyou](https://www.ruby-forum.com/u/daociyiyou)\
**Post date:** [October 31, 2008, 9:31am UTC](https://www.ruby-forum.com/t/about-test-database/152158/4 "2008-10-31T09:31:37Z")

</div>

On Oct 31, 2:09 am, daociyiyou [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> need to consider it because of my application’s logic.  
> Take a look in your app’s test.log and you’ll see for yourself.

Fred

---

<div class="post-metadata">

**Author:** ![daociyiyou](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/0ea827/32.png) [@daociyiyou](https://www.ruby-forum.com/u/daociyiyou)\
**Post date:** [October 31, 2008, 4:50am UTC](https://www.ruby-forum.com/t/about-test-database/152158/5 "2008-10-31T04:50:47Z")

</div>

anyone help me?

---

<div class="post-metadata">

**Author:** ![daociyiyou](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/0ea827/32.png) [@daociyiyou](https://www.ruby-forum.com/u/daociyiyou)\
**Post date:** [October 31, 2008, 1:00pm UTC](https://www.ruby-forum.com/t/about-test-database/152158/6 "2008-10-31T13:00:22Z")

</div>

On Oct 31, 4:31 pm, Frederick C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> > is not in the database at that time?  
> > If the user is still in the database in the following test methods.i  
> > need to consider it because of my application’s logic.
> 
> Take a look in your app’s test.log and you’ll see for yourself.
> 
> Fred

Thank you ,i have found the following words:[4;36;1mSQL (0.032000)  
[0m [0;1mROLLBACK [0m
