# Wierdness with rake test\_units and schema.rb

**URL:** <https://www.ruby-forum.com/t/wierdness-with-rake-test-units-and-schema-rb/62337>\
**Category:** Rails\
**Created:** [June 2, 2006, 8:28pm UTC](https://www.ruby-forum.com/t/wierdness-with-rake-test-units-and-schema-rb/62337 "2006-06-02T20:28:42Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chester\_C](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/ce73a5/32.png) [@Chester\_C](https://www.ruby-forum.com/u/Chester_C)\
**Post date:** [June 2, 2006, 8:28pm UTC](https://www.ruby-forum.com/t/wierdness-with-rake-test-units-and-schema-rb/62337/1 "2006-06-02T20:28:42Z")

</div>

I have just migrated to use Rail 1.1 from 1.0.

In the progress of fixing and cleaning up the unit tests. I found the  
following problem. I am not sure if this is a bug or it is my  
environment.

When I run "rake test\_units, some of the index in association tables is  
not created, this leads to failures for some unit test cases.

Thinking that may be because I didn’t setup the database correctly, I  
reload the sql file (with the index defined) into both test and  
development database.

run the test mannually, i.e. ruby test/units/myclass\_test.rb works fine.

But when I invoke rake test\_units to run all unit tests in a batch, I  
have the same problem again. It seems db/schema.rb generated from the  
rake test\_units has missed some of the indexes definition for some of  
the tables.

Anyone know where I should look to locate the problem? It only occurs to  
some of the tables not all of them. So I think it must be something  
wrong with some of my code somewhere… Thanks in advance.

---

<div class="post-metadata">

**Author:** ![Chester\_C](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/ce73a5/32.png) [@Chester\_C](https://www.ruby-forum.com/u/Chester_C)\
**Post date:** [June 2, 2006, 9:15pm UTC](https://www.ruby-forum.com/t/wierdness-with-rake-test-units-and-schema-rb/62337/2 "2006-06-02T21:15:22Z")

</div>

I had the same problem once. Just run your test\_units manually. I think  
there’s a problem with rake test\_units. I bet that your functional test  
run  
just fine with rake, isn’t it?

---

<div class="post-metadata">

**Author:** ![Chester\_C](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/ce73a5/32.png) [@Chester\_C](https://www.ruby-forum.com/u/Chester_C)\
**Post date:** [June 2, 2006, 9:33pm UTC](https://www.ruby-forum.com/t/wierdness-with-rake-test-units-and-schema-rb/62337/3 "2006-06-02T21:33:43Z")

</div>

On 6/2/06, Chester C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> reload the sql file (with the index defined) into both test and  
> development database.
> 
> run the test mannually, i.e. ruby test/units/myclass\_test.rb works fine.

I have had a similar problem myself, recently. My project has a number  
of  
migrations. When I run rake test:units, it seems to revert to a previous  
migration and wipes out the latest. The schema\_info bit, however, would  
not  
be updated to point at a previous generation, even though the migration  
appeared to be rolled back.

I thought schema.rb might be to blame - does Rake recreate the test  
database  
with that?

---

<div class="post-metadata">

**Author:** ![Chester\_C](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/ce73a5/32.png) [@Chester\_C](https://www.ruby-forum.com/u/Chester_C)\
**Post date:** [June 2, 2006, 10:40pm UTC](https://www.ruby-forum.com/t/wierdness-with-rake-test-units-and-schema-rb/62337/4 "2006-06-02T22:40:54Z")

</div>

Ioana K. wrote:

> I had the same problem once. Just run your test\_units manually. I think  
> there’s a problem with rake test\_units. I bet that your functional test  
> run  
> just fine with rake, isn’t it?

Yup, functional test runs fine.
