Class: Gitlab::Ci::Reports::TestReports

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeTestReports

Returns a new instance of TestReports.


9
10
11
# File 'lib/gitlab/ci/reports/test_reports.rb', line 9

def initialize
  @test_suites = {}
end

Instance Attribute Details

#test_suitesObject (readonly)

Returns the value of attribute test_suites


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

def test_suites
  @test_suites
end

Instance Method Details

#get_suite(suite_name) ⇒ Object


13
14
15
# File 'lib/gitlab/ci/reports/test_reports.rb', line 13

def get_suite(suite_name)
  test_suites[suite_name] ||= TestSuite.new(suite_name)
end

#suite_errorsObject


45
46
47
# File 'lib/gitlab/ci/reports/test_reports.rb', line 45

def suite_errors
  test_suites.transform_values(&:suite_error).compact
end

#total_countObject

rubocop: disable CodeReuse/ActiveRecord


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

def total_count
  test_suites.values.sum(&:total_count)
end

#total_statusObject

rubocop: enable CodeReuse/ActiveRecord


29
30
31
32
33
34
35
# File 'lib/gitlab/ci/reports/test_reports.rb', line 29

def total_status
  if failed_count > 0 || error_count > 0
    TestCase::STATUS_FAILED
  else
    TestCase::STATUS_SUCCESS
  end
end

#total_timeObject

rubocop: disable CodeReuse/ActiveRecord


18
19
20
# File 'lib/gitlab/ci/reports/test_reports.rb', line 18

def total_time
  test_suites.values.sum(&:total_time)
end

#with_attachment!Object


37
38
39
40
41
42
43
# File 'lib/gitlab/ci/reports/test_reports.rb', line 37

def with_attachment!
  @test_suites.keep_if do |_job_name, test_suite|
    test_suite.with_attachment!.present?
  end

  self
end