Turn on Full Backtrace in Ruby on Rails Testcase

Turn on full backtrace in Ruby on Rails TestCase

BACKTRACE=blegga rake test

BACKTRACE=blegga rails test # rails 5+

Append --trace if you need rake related log.

How to get stack trace from a Test::Unit::TestCase

Looking through the code of Test::Unit in Ruby 1.8, it seems all the errors go through the Test::Unit::Error object which filters the backtrace in its #long_display method. There is no configuration and all runners will use the same filtered trace.

Brute force monkey patch to get the whole trace: (I put this in my single test case file; perhaps you could put it in a test helper)

require 'test/unit/util/backtracefilter'

module Test::Unit::Util::BacktraceFilter
def filter_backtrace(backtrace, prefix=nil)
backtrace
end
end

And monkey patch for Ruby 1.9 (which uses minitest)

def MiniTest.filter_backtrace(bt)
bt
end

How to disable rendering the view in ActionController TestCase (Rails 3.0.9)

I had the same problem of disabling just layout, while still rendering the main view. With rspec mocks this works for me:

@controller.stub(:layout).and_return(false)

I've never used rr, but I would imagine the syntax might be as follows:

stub(@controller).layout { false }

How to get rspec-2 to give the full trace associated with a test failure?

You must run rspec with -b option to see full backtraces



Related Topics



Leave a reply



Submit