我有一个单元测试(示例已修改为Test::Unit documentation)
require 'test/unit'
class TC_MyTest < Test::Unit::TestCase
def test_something
assert(true)
end
end
当我执行它时,我得到:
Loaded suite C:/test
Started
.
Finished in 0.0 seconds.
1 tests, 1 assertions, 0 failures, 0 errors
我想得到这样的东西(输出test_something
):
Loaded suite C:/test
Started
test_something
.
Finished in 0.0 seconds.
1 tests, 1 assertions, 0 failures, 0 errors
答案 0 :(得分:15)
如果您正在使用rails进行测试,则可以使用
rake test TESTOPTS=-v
答案 1 :(得分:8)
使用verbose选项运行单元测试。
test.rb -v v
或
test.rb --verbose=verbose
输出:
Loaded suite C:/test
Started
test_something(TC_MyTest): .
Finished in 0.0 seconds.
1 tests, 1 assertions, 0 failures, 0 errors
答案 2 :(得分:4)
如果要创建自己的测试运行器,命令行选项不起作用:
Test::Unit::UI::Console::TestRunner.run(TC_MyTest)
您必须在测试运行器中指定详细程度。 Test::Unit::UI options是:
SILENT = 0,PROGRESS_ONLY = 1,NORMAL = 2,VERBOSE = 3.
所以,对于详细:
Test::Unit::UI::Console::TestRunner.run(TC_MyTest, 3)