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



41
42
43
# File 'lib/gitlab/ci/reports/test_report.rb', line 41

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

#total_countObject



21
22
23
# File 'lib/gitlab/ci/reports/test_report.rb', line 21

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

#total_statusObject



25
26
27
28
29
30
31
# File 'lib/gitlab/ci/reports/test_report.rb', line 25

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

#total_timeObject



17
18
19
# File 'lib/gitlab/ci/reports/test_report.rb', line 17

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

#with_attachment!Object



33
34
35
36
37
38
39
# File 'lib/gitlab/ci/reports/test_report.rb', line 33

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

  self
end