1

For some reason the line number where unit test is failing is not show. New in Rails 3? I'm not sure. This makes it very difficult to know where the test is failing. The only way to know which line is causes the error is to put debug statements everwhere in your test code.

Example of the output is below. The example shows a lot of useful information. For example the error message: wrong number of arguments (o for 2). Unfortunately it doesn't show the line number of the unit test code line. Is it possibly to get the line number?

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!
4

1 回答 1

0

我最近遇到了这个问题;事实证明,我编写了一个测试套件本身失败的测试。(最小密码长度:8 个字符。然后我设置了一个 6 个字符的示例。)我花了很长时间才弄清楚问题,因为错误消息是无意义的。

于 2012-08-03T13:58:51.227 回答