Class: RightScaleSelfService::Test::ShellReport

Inherits:
Report
  • Object
show all
Defined in:
lib/rightscale_selfservice/test/shell_report.rb

Instance Attribute Summary

Attributes inherited from Report

#options, #suite

Instance Method Summary collapse

Constructor Details

#initialize(suite, options = {}) ⇒ ShellReport

Returns a new instance of ShellReport.



27
28
29
30
31
32
33
34
35
36
37
# File 'lib/rightscale_selfservice/test/shell_report.rb', line 27

def initialize(suite, options={})
  super(suite,options)
  @reported_templates = []
  @keyword_substitutions = {
    "SUCCESS" => "\e[42m\e[30mSUCCESS\e[0m",
    "FAILED" => "\e[41m\e[30mFAILED\e[0m",
    "FAILED (EXPECTED)" => "\e[43m\e[30mFAILED (EXPECTED)\e[0m",
    "ERROR" => "\e[41m\e[30mERROR\e[0m",
    "FIXED" => "\e[44m\e[30mFIXED\e[0m"
  }
end

Instance Method Details

#errorsObject



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/rightscale_selfservice/test/shell_report.rb', line 51

def errors
  finished_templates = self.suite.templates.select{|t| t.state == "finished"}
  if finished_templates.size == self.suite.templates.size
    to_puts = ""
    self.suite.templates.each do |template|
      cases_with_errors = template.cases.select{|c| c.errors.size > 0}
      if template.errors.size > 0 ||  cases_with_errors.size > 0
        to_puts += "#{template.name}:\n"
      end
      template.errors.each do |error|
        to_puts += "  #{error}\n"
      end
      cases_with_errors.each do |case_with_errors|
        to_puts += "  #{get_case_type_and_name(case_with_errors)}:\n"
        case_with_errors.errors.each do |error|
          to_puts += "    #{error}\n"
        end
      end
    end
    if to_puts.size > 0
      puts "\e[41m\e[30mERRORS:\e[0m"
      puts "\e[31m#{to_puts}\e[0m"
    end
  end
end

#failuresObject



77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/rightscale_selfservice/test/shell_report.rb', line 77

def failures
  finished_templates = self.suite.templates.select{|t| t.state == "finished"}
  to_puts = ""
  if finished_templates.size == self.suite.templates.size
    to_puts = ""
    self.suite.templates.each do |template|
      cases_with_failures = template.cases.select{|c| c.failures.size > 0}
      if cases_with_failures.size > 0
        to_puts += "#{template.name}:\n"
      end
      cases_with_failures.each do |case_with_fail|
        to_puts += "  #{get_case_type_and_name(case_with_fail)}:\n"
        # TODO: Add details for an operation case type to differentiate
        # them. This is probably an argument for having some of the
        # progress, error, and failure reporting live in the case
        # class, but we don't want the case class to have to know details
        # about how to output. Hrrmnn.
        case_with_fail.failures.each do |failure|
          to_puts += "    #{failure}\n"
        end
      end
    end
    if to_puts.size > 0
      to_puts = "Failures:\n#{to_puts}"
      puts to_puts
    end
  end
end

#progressObject



39
40
41
42
43
44
45
46
47
48
49
# File 'lib/rightscale_selfservice/test/shell_report.rb', line 39

def progress
  self.suite.templates.each do |template|
    if template.state == "finished" && !@reported_templates.include?(template)
      puts "#{template.name}: #{template.state}"
      template.cases.each do |testcase|
        puts "  #{get_case_type_and_name(testcase)}: #{@keyword_substitutions[testcase.result]}"
      end
      @reported_templates << template
    end
  end
end