Class: Test::Unit::TestSuite
- Inherits:
-
Object
- Object
- Test::Unit::TestSuite
- Defined in:
- lib/test_timer.rb
Overview
EXPERIMENTAL Show a report of the time each test takes to run
Constant Summary collapse
- @@test_benchmarks =
{}
Instance Method Summary collapse
-
#run(result) {|STARTED, name| ... } ⇒ Object
Runs the tests and/or suites contained in this TestSuite.
Instance Method Details
#run(result) {|STARTED, name| ... } ⇒ Object
Runs the tests and/or suites contained in this TestSuite.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/test_timer.rb', line 11 def run(result, &progress_block) yield(STARTED, name) @tests.each do |test| start_single_test = Time.now test.run(result, &progress_block) @@test_benchmarks[test.name] = Time.now - start_single_test # print sprintf("#{test.name} %.3f", Time.now - start_single_test) + " " end yield(FINISHED, name) puts "\nTEST BENCHMARK REPORT" @@test_benchmarks.keys.sort{|a, b| @@test_benchmarks[a] <=> @@test_benchmarks[b]}.each do |key| value = @@test_benchmarks[key] puts(("%0.3f" % value) + " #{key}") if /^test_/.match(key) end end |