当运行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.
是否有可能将我自己的文字写入此堆栈?
提前致谢 彼得
答案 0 :(得分:1)
大多数断言采用message
参数,例如:
assert_equal 64, obj.size, "Size should be 64"
如果断言失败,除了通常的测试输出外,还会显示该消息。