sameera207
sameera207

Reputation: 16629

Unit test runs three times

I'm trying to run a single unit test in my Rails app, I'm using the following command to run the test (say my model is users)

rake test TEST=test/unit/user_test.rb

It runs with out a problem, but for some reason it runs three times; can anyone explain me why is that and if I'm doing something wrong above? Following is my gem env, and I'm using Rails 2.3.2.

RubyGems Environment:
  - RUBYGEMS VERSION: 1.8.10
  - RUBY VERSION: 1.8.7 (2011-12-28 patchlevel 357) [x86_64-linux]
  - INSTALLATION DIRECTORY: /home/sameera/.rvm/gems/ruby-1.8.7-p357
  - RUBY EXECUTABLE: /home/sameera/.rvm/rubies/ruby-1.8.7-p357/bin/ruby
  - EXECUTABLE DIRECTORY: /home/sameera/.rvm/gems/ruby-1.8.7-p357/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-linux
  - GEM PATHS:
     - /home/sameera/.rvm/gems/ruby-1.8.7-p357
     - /home/sameera/.rvm/gems/ruby-1.8.7-p357@global
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :benchmark => false
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - http://rubygems.org/

Upvotes: 3

Views: 457

Answers (1)

Frederick Cheung
Frederick Cheung

Reputation: 84134

In a rails app rake test runs 3 subtasks, test:units, test:functionals, test:integration.

Each of those tasks just runs all the tests from the corresponding folder, but your environment variable overrides that search process and so the same file is found each time.

You could either do

rake test:units TEST=...

or

ruby -I test test/unit/user_test.rb

Upvotes: 7

Related Questions