This project is archived and is in readonly mode.

#1708 ✓invalid
hukl

Fixtures starting with "test_" run redundant unit tests

Reported by hukl | January 7th, 2009 @ 05:00 PM | in 2.x

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'

Comments and changes to this ticket

  • Pratik

    Pratik March 8th, 2009 @ 12:17 AM

    • 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.

  • hukl

    hukl March 8th, 2009 @ 02:42 AM

    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?

  • Pratik

    Pratik March 8th, 2009 @ 01:39 PM

    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!

  • hukl

    hukl March 8th, 2009 @ 04:49 PM

    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!

  • Nobuhiro IMAI

    Nobuhiro IMAI May 27th, 2009 @ 07:13 AM

    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?

  • Nobuhiro IMAI

    Nobuhiro IMAI May 30th, 2009 @ 07:31 AM

    • 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?

  • José Valim

    José Valim August 8th, 2009 @ 02:39 PM

    • State changed from “invalid” to “stale”

    Closing as requested in #2992.

  • José Valim

    José Valim August 8th, 2009 @ 02:53 PM

    • State changed from “stale” to “invalid”

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

People watching this ticket

Attachments

Referenced by

Pages