Class: Gitlab::Ci::Reports::TestReport

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeTestReport

Returns a new instance of TestReport.



9
10
11
# File 'lib/gitlab/ci/reports/test_report.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_report.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_report.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_report.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_report.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_report.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_report.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_report.rb', line 37

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

  self
end