Test Confusion


#1

Hi all,

I am getting a different test result depending if I run the test case
directly versus running via “rake test_functional”.

When running directly I get:

ruby test/functional/admin/account_controller_test.rb
Loaded suite test/functional/admin/account_controller_test
Started

Finished in 0.25 seconds.

4 tests, 12 assertions, 0 failures, 0 errors

Yet when I use “rake test_functional”, the first error I get is this:

Started
FEFEFEEFEEE…
Finished in 0.797 seconds.

  1. Failure:
    test_admin_login(AccountControllerTest)
    [c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.0/lib/action_controller/deprecated_assertions.rb:23:in
    assert_session_has' ./test/functional/admin/account_controller_test.rb:29:intest_admin_login’]:
    <:user> is not in the session <#<ActionController::TestSession:0x350ec50
    @attributes={“flash”=>{:notice=>“Login unsuccessful.”}}>>

Don’t know if this has anything to do with it, but I’m getting a lot
of these errors as well:

  1. Error:
    test_admin_login(AccountControllerTest):
    NoMethodError: You have a nil object when you didn’t expect it!
    You might have expected an instance of Array.
    The error occured while evaluating nil.-
    c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.0/lib/active_record/transactions.rb:112:in
    unlock_mutex' c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.0/lib/active_record/fixtures.rb:509:inteardown’

I’m on Rail 0.14.3. Any help is greatly appreciated.

–Ryan


#2

make sure your class names in
functional/admin/account_controller_test.rb and
functional/account_controller_test.rb are not the same

or for that matter, make sure none of your tests have the same class
names