Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3227092
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T16:32:02+00:00 2026-05-17T16:32:02+00:00

Just wondering if there’s a way to run Rails tests without dropping the database.

  • 0

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
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T16:32:03+00:00Added an answer on May 17, 2026 at 4:32 pm

    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 --trace option, this can be proven. Here is the output:

    $ 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
    

    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:load task, 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:

    Recreate the test database from the
    current schema.rb

    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!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.