Class: Gitlab::QA::Report::SummaryTable

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/qa/report/summary_table.rb

Class Method Summary collapse

Class Method Details

.collect_results(input_files) ⇒ Object

rubocop:disable Metrics/AbcSize



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/gitlab/qa/report/summary_table.rb', line 15

def self.collect_results(input_files)
  stage_wise_results = []

  Dir.glob(input_files).each do |report_file|
    stage_hash = {}
    stage_hash["Dev Stage"] = File.basename(report_file, ".*").capitalize

    report_stats = Nokogiri::XML(File.open(report_file)).children[0].attributes

    stage_hash["Total"] = report_stats["tests"].value
    stage_hash["Failures"] = report_stats["failures"].value
    stage_hash["Errors"] = report_stats["errors"].value
    stage_hash["Skipped"] = report_stats["skipped"].value
    stage_hash["Result"] = result_emoji(report_stats)

    stage_wise_results << stage_hash
  end

  stage_wise_results
end

.create(input_files:) ⇒ Object



10
11
12
# File 'lib/gitlab/qa/report/summary_table.rb', line 10

def self.create(input_files:)
  "```\n#{TablePrint::Printer.table_print(collect_results(input_files))}```\n"
end

.result_emoji(report_stats) ⇒ Object

rubocop:enable Metrics/AbcSize



37
38
39
# File 'lib/gitlab/qa/report/summary_table.rb', line 37

def self.result_emoji(report_stats)
  report_stats["failures"].value.to_i.positive? || report_stats["errors"].value.to_i.positive? ? "" : ""
end