After some research, I found that there is no way to do this. The tasks of the test rake will always delete the database, even if you provide the TEST= option, as Bogdan suggests.
Using the --trace , this can be proven. Here is the result:
$ rake test:units TEST=test/unit/post_test.rb --trace (in /Users/johnnyicon/Development/ror/test-app) ** Invoke test:units (first_time) ** Invoke test:prepare (first_time) ** Invoke db:test:prepare (first_time) ** Invoke db:abort_if_pending_migrations (first_time) ** Invoke environment (first_time) ** Execute environment ** Execute db:abort_if_pending_migrations ** Execute db:test:prepare ** Invoke db:test:load (first_time) ** Invoke db:test:purge (first_time) ** Invoke environment ** Execute db:test:purge ** Execute db:test:load ** Invoke db:schema:load (first_time) ** Invoke environment ** Execute db:schema:load ** Execute test:prepare ** Execute test:units
After reading Ruby on Rails Guides for Testing , he describes what some of these tasks mean. The db:test:load task, which you see on the 7th line at the bottom of the output as ** Execute db:test:load deserves special attention. Guides say the following about this task:
Restore test database from current schema.rb
So, even if I were to perform unit tests one by one, as Bogdan suggests, the rake task will recreate the database anyway. Not the answer I was hoping for, but this is no longer a problem.
The reason I asked to start was because I did not have access to another database for testing, so I also used my development database for testing. But since then I was able to get another database designed for testing.
Thank you Bogdan! I appreciate the help!
John
source share