class UIAuto::Formatters::ColorIndentFormatter

Public Class Methods

new() click to toggle source
# File lib/uiauto/formatters/color_indent_formatter.rb, line 7
def initialize
  @passes   = []
  @failures = []
  @current_script = ''
end

Public Instance Methods

element_tree_line(line) click to toggle source
# File lib/uiauto/formatters/color_indent_formatter.rb, line 82
def element_tree_line(line)
  output.puts "    #{line}".color("333333")
end
element_tree_start() click to toggle source
# File lib/uiauto/formatters/color_indent_formatter.rb, line 78
def element_tree_start
  output.puts "    Element Tree:".color("333333")
end
load_simulator_data(path) click to toggle source
# File lib/uiauto/formatters/color_indent_formatter.rb, line 19
def load_simulator_data(path)
  output.puts
  output.puts "  Simulator Data: #{path}"
end
log_debug(message) click to toggle source
# File lib/uiauto/formatters/color_indent_formatter.rb, line 43
def log_debug(message)
  if output.tty?
    colored_message = message.foreground(:cyan)
    colored_message = colored_message.gsub(/"((?:[^"\\]|\\.)*)"/) do
      # hack to ensure ansi start/end codes for cyan are matched between bright cyan
      "\e[0m#{"\"#{$1}\"".bright.foreground(:cyan)}\e[36m"
    end

    message = colored_message
  end
  output.puts "    #{message}"
end
log_default(message) click to toggle source
# File lib/uiauto/formatters/color_indent_formatter.rb, line 60
def log_default(message)
  output.puts message
end
log_error(message) click to toggle source
# File lib/uiauto/formatters/color_indent_formatter.rb, line 56
def log_error(message)
  output.puts "    Error: #{message}".foreground(:red)
end
log_fail(message) click to toggle source
# File lib/uiauto/formatters/color_indent_formatter.rb, line 34
def log_fail(message)
  output.puts "    Test: \"#{message}\" Failed".foreground(:red)
  @failures << "#{@current_script} \"#{message}\""
end
log_issue(message) click to toggle source
# File lib/uiauto/formatters/color_indent_formatter.rb, line 39
def log_issue(message)
  output.puts "    Test: \"#{message}\" Issue".foreground(:yellow)
end
log_none(message) click to toggle source
# File lib/uiauto/formatters/color_indent_formatter.rb, line 68
def log_none(message)
  output.puts "    #{message}".foreground(:red)
  @failures << @current_script unless @failures.include?(@current_script)
end
log_pass(message) click to toggle source
# File lib/uiauto/formatters/color_indent_formatter.rb, line 29
def log_pass(message)
  output.puts "    Test: \"#{message}\" Passed".foreground(:green)
  @passes << message
end
log_start(message) click to toggle source
# File lib/uiauto/formatters/color_indent_formatter.rb, line 24
def log_start(message)
  output.puts
  output.puts "  Test: \"#{message}\""
end
log_stopped(message) click to toggle source
# File lib/uiauto/formatters/color_indent_formatter.rb, line 73
def log_stopped(message)
  output.puts "    #{message}".foreground(:red)
  @failures << @current_script unless @failures.include?(@current_script)
end
log_warning(message) click to toggle source
# File lib/uiauto/formatters/color_indent_formatter.rb, line 64
def log_warning(message)
  output.puts "    Warning: #{message}".foreground(:yellow)
end
run_finish() click to toggle source
# File lib/uiauto/formatters/color_indent_formatter.rb, line 86
def run_finish
  if @failures.count > 0
    output.puts
    output.puts "Failing Tests:".foreground(:red)
    @failures.each do |failure|
      output.puts failure.foreground(:red)
    end
  end

  output.puts
  output.puts "#{@passes.count + @failures.count} tests #{summary}"
end
script_start(script) click to toggle source
# File lib/uiauto/formatters/color_indent_formatter.rb, line 13
def script_start(script)
  output.puts
  output.puts "Script: #{script}"
  @current_script = script
end

Protected Instance Methods

summary() click to toggle source
# File lib/uiauto/formatters/color_indent_formatter.rb, line 101
def summary
  failures = ''
  passes   = ''

  if @failures.count > 0
    failures = "#{@failures.count} failed".foreground(:red)
  end

  if @passes.count > 0
    passes = "#{@passes.count} passed".foreground(:green)
  end

  if failures.length > 0 && passes.length > 0
    "(#{failures}, #{passes})"
  elsif failures.length > 0
    "(#{failures})"
  elsif passes.length > 0
    "(#{passes})"
  end
end