必須是ruby1.8.x的版本,我用的是1.8.6,因?yàn)?.9的版本里邊沒有這個(gè)文件,文件路徑為到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