Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Fixtures starting with "test_" run redundant unit tests

#1708

Rails 2.2.2

When you create an empty app and generate a model called TestFoo you get a fixture file called test_foos.yml.

Now when you run the test you get a pretty wild exception from deep down. When you remove that fixture file, everything runs smoothly. We tried several variations of the naming and it really seems only to occur with the "test_" prefix.

This should be handled more gracefully, or even better, get fixed!

I attached a sample rails app with really only the bare minimum of files and a sqlite3 db. Run rake test:units to get the exception.

The Exception you should get goes like this:

1) Error: test_foos(ActionController::TestCase): ArgumentError: wrong number of arguments (0 for 1)

/opt/local/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/test_case.rb:134:in `initialize'
/opt/local/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/test_case.rb:134:in `new'
/opt/local/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/test_case.rb:134:in `setup_controller_request_and_response'
/opt/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/callbacks.rb:178:in `send'
/opt/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/callbacks.rb:178:in `evaluate_method'
/opt/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/callbacks.rb:166:in `call'
/opt/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/callbacks.rb:90:in `run'
/opt/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/callbacks.rb:90:in `each'
/opt/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/callbacks.rb:90:in `send'
/opt/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/callbacks.rb:90:in `run'
/opt/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/callbacks.rb:277:in `run_callbacks'
/opt/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/testing/setup_and_teardown.rb:58:in `run'

Reported by hukl · January 7th, 2009 @ 05:00 PM

State: invalid
Milestone: 2.x
Assigned to: Pratik Pratik
Importance: none

Activity

  1. Pratik
    Pratik
    • Assigned user set to Pratik
    • State changed from new to invalid

    I tried and it works fine for me. Could you please attach a patch or a failing test ?

    Thanks.

    March 8th, 2009 @ 12:17 AM

  2. hukl
    hukl

    The attached sample app worked for you ? I just downloaded it again and I still got the same exception. This is odd. A co worker of mine tried it on his linux getting the same problem. He even blogged about it:

    http://tech.artcom.de/blog/?p=211

    I really don't know what else to provide. Any ideas how to trace it?

    March 8th, 2009 @ 02:42 AM

  3. Pratik
    Pratik

    Nop, I generated a new Rails app from the edge and added a model called test_foo and tests/fixtures for it. It all worked.

    Thanks!

    March 8th, 2009 @ 01:39 PM

  4. hukl
    hukl

    Alright, its a rails 2.2.2 Problem then.

    I just tried it with Edge/2.3 and its working indeed. Can be set to resolved then.

    Thank you for looking at it!

    March 8th, 2009 @ 04:49 PM

  5. Nobuhiro IMAI
    Nobuhiro IMAI

    Hmm, test works, but redundant test cases appear out of nowhere.
    I hit this with TestResult, and found this ticket.

    $ rake test:units
    (in /tmp/foo)
    /usr/bin/ruby1.8 -I"lib:test" "/home/nov/gems/gems/rake-0.8.7/lib/rake/rake_test_loader.rb" "test/unit/test_foo_test.rb" 
    Loaded suite /home/nov/gems/gems/rake-0.8.7/lib/rake/rake_test_loader
    Started
    ........
    Finished in 0.057495 seconds.
    
    8 tests, 1 assertions, 0 failures, 0 errors
    ^^^^^^^
    $ ruby -I test test/unit/test_foo_test.rb -v
    Loaded suite test/unit/test_foo_test
    Started
    test_foos(ActionController::IntegrationTest): .
    test_foos(ActionController::TestCase): .
    test_foos(ActionMailer::TestCase): .
    test_foos(ActionView::TestCase): .
    test_foos(ActiveRecord::TestCase): .
    test_foos(ActiveSupport::TestCase): .
    test_foos(TestFooTest): .
    test_the_truth(TestFooTest): .
    
    Finished in 0.066047 seconds.
    
    8 tests, 1 assertions, 0 failures, 0 errors
    

    Is this a right behavior?

    May 27th, 2009 @ 07:13 AM

  6. Nobuhiro IMAI
    Nobuhiro IMAI
    • Title changed from Fixtures starting with "test_" will break unit tests to Fixtures starting with "test_" run redundant unit tests
    • Tag changed from 2.2.2, actioncontroller, exceptions, fixtures, test, testing, tests, unit to 2.3.2, activerecord, fixtures, patch, test, testing, tests, unit

    Patch attached. Does it make sense?

    May 30th, 2009 @ 07:31 AM

  7. José Valim
    José Valim
    • State changed from invalid to stale

    Closing as requested in #2992.

    August 8th, 2009 @ 02:39 PM

  8. José Valim
    José Valim
    • State changed from stale to invalid

    August 8th, 2009 @ 02:53 PM