Class: Gitlab::Ci::Reports::TestSuiteSummary

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/ci/reports/test_suite_summary.rb

Instance Method Summary collapse

Constructor Details

#initialize(build_report_results) ⇒ TestSuiteSummary

Returns a new instance of TestSuiteSummary.


7
8
9
# File 'lib/gitlab/ci/reports/test_suite_summary.rb', line 7

def initialize(build_report_results)
  @build_report_results = build_report_results
end

Instance Method Details

#build_idsObject

rubocop: disable CodeReuse/ActiveRecord


16
17
18
# File 'lib/gitlab/ci/reports/test_suite_summary.rb', line 16

def build_ids
  @build_report_results.pluck(:build_id)
end

#error_countObject


36
37
38
# File 'lib/gitlab/ci/reports/test_suite_summary.rb', line 36

def error_count
  @error_count ||= @build_report_results.sum(&:tests_errored)
end

#failed_countObject


28
29
30
# File 'lib/gitlab/ci/reports/test_suite_summary.rb', line 28

def failed_count
  @failed_count ||= @build_report_results.sum(&:tests_failed)
end

#nameObject


11
12
13
# File 'lib/gitlab/ci/reports/test_suite_summary.rb', line 11

def name
  @name ||= @build_report_results.first.tests_name
end

#skipped_countObject


32
33
34
# File 'lib/gitlab/ci/reports/test_suite_summary.rb', line 32

def skipped_count
  @skipped_count ||= @build_report_results.sum(&:tests_skipped)
end

#success_countObject


24
25
26
# File 'lib/gitlab/ci/reports/test_suite_summary.rb', line 24

def success_count
  @success_count ||= @build_report_results.sum(&:tests_success)
end

#to_hObject

rubocop: disable CodeReuse/ActiveRecord


45
46
47
48
49
50
51
52
53
54
# File 'lib/gitlab/ci/reports/test_suite_summary.rb', line 45

def to_h
  {
    time: total_time,
    count: total_count,
    success: success_count,
    failed: failed_count,
    skipped: skipped_count,
    error: error_count
  }
end

#total_countObject


40
41
42
# File 'lib/gitlab/ci/reports/test_suite_summary.rb', line 40

def total_count
  @total_count ||= [success_count, failed_count, skipped_count, error_count].sum
end

#total_timeObject


20
21
22
# File 'lib/gitlab/ci/reports/test_suite_summary.rb', line 20

def total_time
  @total_time ||= @build_report_results.sum(&:tests_duration)
end