【发布时间】:2011-12-09 19:30:08
【问题描述】:
我的 ruby 脚本中有断言。
这些断言中的每一个都有一个描述断言的消息。
所以我有两个关于这个的问题
我希望与每个断言关联的消息显示为 测试进展。目前消息仅在有任何事情时显示 失败
当任何断言失败时,整个测试都会退出。我怎么做 即使一个断言失败,测试也会继续?
我正在使用的示例代码
assert_match("hey", "hey this is a test", "The word exists in the string")
所以当前的输出看起来像 -
ruby ruby11.rb -v v
Loaded suite ruby
Started
test_ruby(Ruby):
F
Finished in 40.555587 seconds.
1) Failure:
test_ruby11(Ruby11) [ruby11.rb:73]:
Text box not displayed
<false> is not true.
1 tests, 3 assertions, 1 failures, 0 errors
我希望它看起来像
ruby ruby.rb -v v
Loaded suite ruby
Started
test_ruby(Ruby):
F
ok 1 - First test successful
ok 2 - The text is displayed
ok 3 - The image is present
not ok 4 - Text box not displayed
ok - The picture is visible
Finished in 40.555587 seconds.
1) Failure:
test_ruby(Ruby) [ruby11.rb:73]:
Text box not displayed
<false> is not true.
1 tests, 4 assertions, 1 failures, 0 errors
所以在上面想要的显示中,所有的断言状态都显示为测试执行时的状态。 (类似于 perl 中的 TAP)。 我是 ruby 新手,所以我确信我做错了一些基本的事情。
我还在运行脚本时尝试了详细参数ruby ruby.rb -v v。但这也无济于事。
感谢您的帮助
【问题讨论】:
-
ruby ruby.rb --verbose呢?
标签: ruby unit-testing testunit tap