class Robottelo::Reporter::Runner

The Minitest Report Runner

Attributes

io[RW]
options[RW]

Public Class Methods

new(io = $stdout, options = {}) click to toggle source
# File lib/robottelo/reporter.rb, line 15
def initialize(io = $stdout, options = {})
  @io = io
  @options = options
  report_file_name = ENV[ENV_ROBOTTELO_REPORT_NAME] || "robottelo-results.xml"
  ci_reports_path = ENV[ENV_CI_REPORTS] || File.expand_path("#{Dir.getwd}/test/reports")
  report_dir = "#{ci_reports_path}/robottelo"
  report_file_path = ENV[ENV_ROBOTTELO_REPORT_PATH] || "#{report_dir}/#{report_file_name}"
  @report_file_path = File.expand_path(report_file_path)
  @io.puts 'Robottelo Reporter initialization'
  @xml_results = Robottelo::Reporter::ResultsToXML.new
  @last_test_properties = {}
  @last_test_klass = nil
  @last_test_meth = nil
  @last_test_meth = nil
end

Public Instance Methods

prerecord(klass, name) click to toggle source
# File lib/robottelo/reporter.rb, line 36
def prerecord(klass, name)
  # This is the last chance to have access to the test class
  @last_test_properties = Robottelo::Reporter.test_attributes klass, name
  @last_test_klass = klass.to_s
  @last_test_meth = name
end
record(result) click to toggle source
# File lib/robottelo/reporter.rb, line 43
def record(result)
  pid = @last_test_properties[TEST_ATTRIBUTE_ID]
  # record only if pid attribute exists
  unless pid.nil?
    test_result = Robottelo::Reporter::TestResult.new(
      @last_test_klass,
      @last_test_meth,
      result.time,
      result.assertions,
      result.failures,
      @last_test_properties
    )
    @xml_results.record test_result
  end
  @last_test_properties = {}
end
report() click to toggle source
# File lib/robottelo/reporter.rb, line 60
def report
  File.open @report_file_path, 'w' do |f|
    f << @xml_results.build
  end
  @io.puts "\nRobottelo Reporter build finished: #{@report_file_path}"
end
start() click to toggle source
# File lib/robottelo/reporter.rb, line 31
def start
  # create the target dir if it does not exist
  FileUtils.mkdir_p File.dirname(@report_file_path)
end