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.

ActiveSupport::Testing::SetupAndTeardown::run_with_callbacks_and_mocha does not record Exceptions as test errors

#1719

Rails 2.2.2 mocha gem installed

run this unit test

require "test_helper" class BugTest < ActiveSupport::TestCase def test_bug raise Exception, "this should have been a test error but wasn't" end end

rake test:units

test/unit/bugtest.rb:5:in test_bug': this should have been a test error but wasn't (Exception)

from /Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active_support/testing/setup_and_teardown.rb:94:in `__send__'
from /Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active_support/testing/setup_and_teardown.rb:94:in `run'
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/test/unit/testsuite.rb:34:in `run'
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/test/unit/testsuite.rb:33:in `each'
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/test/unit/testsuite.rb:33:in `run'
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/test/unit/testsuite.rb:34:in `run'
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/test/unit/testsuite.rb:33:in `each'
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/test/unit/testsuite.rb:33:in `run'
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/test/unit/ui/testrunnermediator.rb:46:in `run_suite'
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/test/unit/ui/console/testrunner.rb:67:in `start_mediator'
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/test/unit/ui/console/testrunner.rb:41:in `start'
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/test/unit/ui/testrunnerutilities.rb:29:in `run'
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/test/unit/autorunner.rb:216:in `run'
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/test/unit/autorunner.rb:12:in `run'
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/test/unit.rb:278
from test/unit/bugtest.rb:4

it appears that run_with_callbacks_and_mocha does not catch Exception (or the Passthrough exceptions) like run_with_callbacks_and_testunit does.

That means any thrown Exception or Subclass of Exception kills the test run, and thus breaks our continuous build.

I'm not in the know about why run_with_callbacks_and_mocha is written this way but it looks like bug to me.

Reported by Geoff Longman · January 9th, 2009 @ 04:38 PM

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

Activity

  1. Geoff Longman
    Geoff Longman

    formatting test case...

    
    require "test_helper"
    class BugTest < ActiveSupport::TestCase
     def test_bug
       raise Exception, "this should have been a test error but wasn't"
     end
    end
    
    >> rake test:units
    

    January 9th, 2009 @ 04:41 PM

  2. Geoff Longman
    Geoff Longman

    I should add that if mocha is not present the problem does not appear.

    January 9th, 2009 @ 09:05 PM

  3. Pratik
    Pratik
    • State changed from new to stale

    Is this still an issue on the edge ?

    March 10th, 2009 @ 12:19 PM

  4. CancelProfileIsBroken
    CancelProfileIsBroken
    • Tag changed from 2.2.2, active_support, mocha, testing to 2.2.2, active_support, bugmash, mocha, testing

    August 3rd, 2009 @ 02:30 PM

  5. Arthur Zapparoli
    Arthur Zapparoli

    not reproducible in 2-3-stable

    created the bug_test.rb file above, and it reproduced a test Error, instead of killing the test run.

    August 9th, 2009 @ 05:45 AM

  6. Rizwan Reza
    Rizwan Reza
    • Tag changed from 2.2.2, active_support, bugmash, mocha, testing to 2.2.2, active_support, bugmash, invalid, mocha, testing

    not reproducible

    -1 Same as Arthur. I manually tested in a sample app.

    August 9th, 2009 @ 11:34 PM

  7. José Valim
    José Valim
    • Tag changed from 2.2.2, active_support, bugmash, invalid, mocha, testing to 2.2.2, active_support, invalid, mocha, testing
    • State changed from stale to invalid

    August 9th, 2009 @ 11:35 PM