必须是ruby1.8.x的版本,我用的是1.8.6,因为1.9的版本里边没有这个文件,文件路径为到ruby的安装目录下的/test/unit/testcase.rb路径下
def run(result)
yield(STARTED, name)
@_result = result
begin
setup
puts "Test method:#{self}"
num="#{self}".scan(/d{1}/)[1]
puts "this is the #{num} testcase"
#puts "this is the d{1,} testcase"
time=Time.now
__send__(@method_name)
difference = Time.now - time
seconds = difference % 60
#sec=seconds.to_s.scan(/d*/)[0]
sec=seconds.round
difference = (difference - seconds) / 60
minutes = (difference % 60).round
difference = (difference - minutes) / 60
hours = (difference % 24).round
puts "Runtime is: #{hours} hours #{minutes} minutes #{sec} seconds"
rescue AssertionFailedError => e
add_failure(e.message, e.backtrace)
rescue StandardError, ScriptError
add_error($!)
ensure
begin
teardown
rescue AssertionFailedError => e
add_failure(e.message, e.backtrace)
rescue StandardError, ScriptError
add_error($!)
end
end
result.add_run
yield(FINISHED, name)
end