Test Databases - do a rake migrate if you change the structure
Some of the functional tests were failing because of a missing column in a table. Took us some time to figure out the real issue.
Added an extra column 'x' using rails migration. Ran the functional tests to make sure that they all pass.
They failed, complaining that there was no column 'x' present.
Decided to check the test_database to see if that new column was created in the table. And it was not.
The way rails handles testing, it creates a test_database using the structure of the tables in the development_database and populates the tables using the fixtures. Hence if the development_database is not current (w.r.t the migration scripts) then the test database too does not have the latest structure.
Ran the migrate task. Got the development_database synched up and ran the tests.
Voila. All passed :-)
Added an extra column 'x' using rails migration. Ran the functional tests to make sure that they all pass.
They failed, complaining that there was no column 'x' present.
Decided to check the test_database to see if that new column was created in the table. And it was not.
The way rails handles testing, it creates a test_database using the structure of the tables in the development_database and populates the tables using the fixtures. Hence if the development_database is not current (w.r.t the migration scripts) then the test database too does not have the latest structure.
Ran the migrate task. Got the development_database synched up and ran the tests.
Voila. All passed :-)
0 Comments:
Post a Comment
<< Home