Class: Minitest::Reporter
- Defined in:
- lib/minitest.rb,
lib/minitest/parallel_each.rb
Overview
Collects and reports the result of all runs.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#assertions ⇒ Object
The count of assertions run.
-
#count ⇒ Object
The count of runnable methods ran.
-
#io ⇒ Object
The IO used to report.
-
#old_sync ⇒ Object
:nodoc:.
-
#options ⇒ Object
Command-line options for this run.
-
#results ⇒ Object
The results of all the runs.
-
#start_time ⇒ Object
The start time of the run.
-
#sync ⇒ Object
:nodoc:.
Class Method Summary collapse
-
.synchronize ⇒ Object
:nodoc:.
Instance Method Summary collapse
-
#initialize(io = $stdout, options = {}) ⇒ Reporter
constructor
:nodoc:.
-
#passed? ⇒ Boolean
Did this run pass?.
-
#record(result) ⇒ Object
Record a result and output the Runnable#result_code.
-
#report ⇒ Object
Outputs the summary of the run.
-
#run_and_report ⇒ Object
Top-level method to ensure that start and report are called.
-
#simple_record ⇒ Object
Record a result and output the Runnable#result_code.
-
#start ⇒ Object
Starts reporting on the run.
Constructor Details
#initialize(io = $stdout, options = {}) ⇒ Reporter
:nodoc:
368 369 370 371 372 373 374 375 376 |
# File 'lib/minitest.rb', line 368 def initialize io = $stdout, = {} # :nodoc: self.io = io self. = self.assertions = 0 self.count = 0 self.results = [] self.start_time = nil end |
Instance Attribute Details
#assertions ⇒ Object
The count of assertions run.
339 340 341 |
# File 'lib/minitest.rb', line 339 def assertions @assertions end |
#count ⇒ Object
The count of runnable methods ran.
344 345 346 |
# File 'lib/minitest.rb', line 344 def count @count end |
#old_sync ⇒ Object
:nodoc:
366 367 368 |
# File 'lib/minitest.rb', line 366 def old_sync @old_sync end |
#options ⇒ Object
Command-line options for this run.
354 355 356 |
# File 'lib/minitest.rb', line 354 def @options end |
#results ⇒ Object
The results of all the runs. (Non-passing only to cut down on memory)
359 360 361 |
# File 'lib/minitest.rb', line 359 def results @results end |
#start_time ⇒ Object
The start time of the run.
364 365 366 |
# File 'lib/minitest.rb', line 364 def start_time @start_time end |
Class Method Details
.synchronize ⇒ Object
:nodoc:
91 92 93 94 95 96 97 |
# File 'lib/minitest/parallel_each.rb', line 91 def self.synchronize # :nodoc: if @mutex then # see parallel_each.rb @mutex.synchronize { yield } else yield end end |
Instance Method Details
#passed? ⇒ Boolean
Did this run pass?
381 382 383 |
# File 'lib/minitest.rb', line 381 def passed? results.all?(&:skipped?) end |
#record(result) ⇒ Object
Record a result and output the Runnable#result_code. Stores the result of the run if the run did not pass.
416 417 418 419 420 421 422 423 424 425 426 |
# File 'lib/minitest.rb', line 416 def record result self.count += 1 self.assertions += result.assertions io.print "%s#%s = %.2f s = " % [result.class, result.name, result.time] if [:verbose] io.print result.result_code io.puts if [:verbose] results << result if not result.passed? or result.skipped? end |
#report ⇒ Object
Outputs the summary of the run.
431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 |
# File 'lib/minitest.rb', line 431 def report aggregate = results.group_by { |r| r.failure.class } aggregate.default = [] # dumb. group_by should provide this f = aggregate[Assertion].size e = aggregate[UnexpectedError].size s = aggregate[Skip].size t = Time.now - start_time io.puts # finish the dots io.puts io.puts "Finished in %.6fs, %.4f runs/s, %.4f assertions/s." % [t, count / t, self.assertions / t] format = "%d runs, %d assertions, %d failures, %d errors, %d skips" summary = format % [count, self.assertions, f, e, s] filtered_results = results.dup filtered_results.reject!(&:skipped?) unless [:verbose] filtered_results.each_with_index do |result, i| io.puts "\n%3d) %s" % [i+1, result] end io.puts io.puts summary io.sync = self.old_sync if self.sync end |
#run_and_report ⇒ Object
Top-level method to ensure that start and report are called. Yields to the caller.
389 390 391 392 393 394 395 |
# File 'lib/minitest.rb', line 389 def run_and_report start yield report end |
#simple_record ⇒ Object
Record a result and output the Runnable#result_code. Stores the result of the run if the run did not pass.
99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/minitest/parallel_each.rb', line 99 def record result self.count += 1 self.assertions += result.assertions io.print "%s#%s = %.2f s = " % [result.class, result.name, result.time] if [:verbose] io.print result.result_code io.puts if [:verbose] results << result if not result.passed? or result.skipped? end |
#start ⇒ Object
Starts reporting on the run.
400 401 402 403 404 405 406 407 408 409 410 |
# File 'lib/minitest.rb', line 400 def start self.sync = io.respond_to? :"sync=" # stupid emacs self.old_sync, io.sync = io.sync, true if self.sync self.start_time = Time.now io.puts "Run options: #{[:args]}" io.puts io.puts "# Running:" io.puts end |