Just wondering if there’s a way to run Rails tests without dropping the database. I’m currently only executing unit tests and am using the following rake command to do so: rake test:units.
Thanks for the help in advance!
Just in case this is relevant:
- Rails 3
- Ruby 1.8.7 (MRI)
- Oracle 11g Database
- activerecord-oracle_enhanced-adapter
After doing some research, I have found that there isn’t a way to do this. The test rake tasks will always drop the database, even when providing the
TEST=option as Bohdan suggests.By using the
--traceoption, this can be proven. Here is the output:Reading through the Ruby on Rails Guides for Testing, it describes what some of these rake tasks mean. The one to pay particular attention to is the
db:test:loadtask, which you see on the 7th line from the bottom of the output as** Execute db:test:load. The guides say the following about this task:So even if I were to execute the unit tests one by one as Bohdan suggests, the rake task would still recreate the database. Not the answer I was hoping for, but it isn’t a problem anymore.
The reason I was asking to begin with was because I did not have access to another database to use for testing, so I was using my development database for testing as well. But since then, I’ve been able to get another database dedicated for testing.
Thanks anyway Bohdan! I appreciate the help!