Class: Moto::Reporting::Listeners::ConsoleDots

Inherits:
Base
  • Object
show all
Defined in:
lib/reporting/listeners/console_dots.rb

Instance Attribute Summary

Attributes inherited from Base

#run_params

Instance Method Summary collapse

Methods inherited from Base

#start_run, #start_test

Constructor Details

#initialize(run_params) ⇒ ConsoleDots

Returns a new instance of ConsoleDots.



8
9
10
11
# File 'lib/reporting/listeners/console_dots.rb', line 8

def initialize(run_params)
  @displayed_results = 0
  @semaphore = Mutex.new
end

Instance Method Details

#end_run(run_status) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/reporting/listeners/console_dots.rb', line 13

def end_run(run_status)
  puts ''
  puts ''
  puts "FINISHED: #{run_status.to_s}, duration: #{Time.at(run_status.duration).utc.strftime("%H:%M:%S")}"
  puts "Tests executed: #{run_status.tests_all.length}"
  puts "  Passed:       #{run_status.tests_passed.length}"
  puts "  Failure:      #{run_status.tests_failed.length}"
  puts "  Error:        #{run_status.tests_error.length}"
  puts "  Skipped:      #{run_status.tests_skipped.length}"

  if run_status.tests_failed.length > 0
    puts ''
    puts 'FAILURES: '
    run_status.tests_failed.each do |test_status|
      puts test_status.display_name
      puts "\t" + test_status.results.last.failures.join("\n\t")
      puts ''
    end
  end

  if run_status.tests_error.length > 0
    puts ''
    puts 'ERRORS: '
    run_status.tests_error.each do |test_status|
      puts test_status.display_name
      puts "\t" + test_status.results.last.message
      puts ''
    end
  end

  if run_status.tests_skipped.length > 0
    puts ''
    puts 'SKIPPED: '
    run_status.tests_skipped.each do |test_status|
      puts test_status.display_name
      puts "\t" + test_status.results.last.message
      puts ''
    end
  end

end

#end_test(test_status) ⇒ Object



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/reporting/listeners/console_dots.rb', line 55

def end_test(test_status)
  @semaphore.synchronize do
    @displayed_results += 1

    representation =
        case test_status.results.last.code
          when Moto::Test::Result::PASSED   then '.'
          when Moto::Test::Result::FAILURE  then 'F'
          when Moto::Test::Result::ERROR    then 'E'
          when Moto::Test::Result::SKIPPED  then 's'
        end

    if @displayed_results%50 != 0
      print representation
    else
      puts representation
    end
    $stdout.flush

  end
end