Uninitialized constant Test (NameError)


#1

I have three Rails apps on my laptop.

Two can runs tests just fine.

The third generates this error when I try to run any tests:

/usr/local/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/
active_support/dependencies.rb:200:in `const_missing’:
uninitialized constant Test (NameError)
from ./test/unit/…/test_helper.rb:5
from ./test/unit/album_test.rb:1
from /usr/local/lib/ruby/gems/1.8/gems/rake-0.6.2/lib/rake/
rake_test_loader.rb:5
from /usr/local/lib/ruby/gems/1.8/gems/rake-0.6.2/lib/rake/
rake_test_loader.rb:5

I found this reference on Google, which seems related, but no answer
was provided:

http://wrath.rubyonrails.org/pipermail/rails/2006-January/009628.html

I get the same error whether I run a single test at a time or a full
rake set.

I’ve checked config files, and all seems OK.

I’m really pulling my hair out on this. Any help would be appreciated.


– Tom M.


#2

If you run debian or debian-based distribution like Ubuntu, make sure
that you have unit test package installed (libtest-unit-ruby).

Kent.


#3

Thanks, Kent.

Notice that 2 of 3 apps can run unit tests just fine. :slight_smile:


– Tom M.


#4

Hey Tom,

I faced this same problem recently as well. It turns out that I had a
require in app/controllers/application.rb that wasn’t finding the file,
and
was causing an exception to be thrown. Somehow, this got in the way of
loading ‘test/unit.’ (Oddly enough, the tests all worked fine on
windows. It
turns out my bug was related to the fact that filenames on unix are case
sensitive, but they aren’t on windows!).

I dont think thats the exact same problem with yours, since its failing
on a
unit test, not a functional test, but it may be a similar type of error.

Try running ‘rake test_units --trace’ to see if you can find a more
useful
error message.

Maurice


#5

Thank you so much.

That was exactly the problem.

Weird error message, that!


– Tom M.