2010-01-06 95 views
1

当运行Rails的单元测试,我得到的输出指定的行号和方法在测试失败时,例如:Rails的单元测试:如何我自己的输出添加到单元测试结果

1) Failure: 
test_05_photo_tag_add_remove(TC_javascript02Test) 
    [./helper/helper.rb:6:in `handle_assert' 
    ./helper/helper.rb:17:in `check_not_string' 
    ./helper/helper.rb:134:in `check_for_ajax_remove_string' 
    javascript.rb:39:in `test_05_photo_tag_add_remove']: 
<false> is not true. 

是否有可能DD我自己的文本到这个堆栈?

预先感谢 彼得

回答

1

大多数断言采取message参数,例如:

assert_equal 64, obj.size, "Size should be 64" 

如果断言失败,该消息将在除通常的测试输出显示。

+0

谢谢你,Alex – Peter 2010-01-07 18:53:54