1
出於某種原因,未顯示單元測試失敗的行號。 Rails 3中的新功能?我不確定。這使得很難知道測試失敗的地方。知道哪一行導致錯誤的唯一方法是在測試代碼的任何地方放置調試語句。顯示Rails測試失敗的行號
輸出示例如下。這個例子顯示了很多有用的信息。例如錯誤消息:參數的錯誤數量(o代表2)。不幸的是,它不顯示單元測試代碼行的行號。是否有可能獲得行號?
ActionController::TestCase
ActionDispatch::IntegrationTest
ActiveRecord::TestCase
ActiveSupport::TestCase
DefineIssueTest
test_Get_issues ERROR
wrong number of arguments (0 for 2)
STDERR:
Exception `ArgumentError' at c:/Ruby19/lib/ruby/gems/1.9.1/gems/activesu
pport-3.1.4/lib/active_support/testing/setup_and_teardown.rb:35:in `block in run
'
c:/Ruby19/lib/ruby/gems/1.9.1/gems/activesupport-3.1.4/lib/active_suppor
t/callbacks.rb:408:in `_run_setup_callbacks'
c:/Ruby19/lib/ruby/gems/1.9.1/gems/activesupport-3.1.4/lib/active_suppor
t/callbacks.rb:81:in `run_callbacks'
c:/Ruby19/lib/ruby/gems/1.9.1/gems/activesupport-3.1.4/lib/active_suppor
t/testing/setup_and_teardown.rb:34:in `run'
Test::Unit::TestCase
==============================================================================
pass: 0, fail: 0, error: 1
total: 1 tests with 20 assertions in 0.935994 seconds
==============================================================================
Errors running test:single!
目前我正在添加跟蹤語句以確定最後成功執行的測試代碼行。我必須做錯什麼? Rails必須有更好的方式來做到這一點? – onknows 2012-08-02 11:49:53
該錯誤似乎源於active_support/testing中的「setup_and_teardown」方法。你有沒有用於測試的設置代碼,可能會失敗? – Frost 2012-08-02 12:56:23