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



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

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



8
9
10
# File 'lib/gitlab/qa/report/summary_table.rb', line 8

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



35
36
37
# File 'lib/gitlab/qa/report/summary_table.rb', line 35

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