Class: Gitlab::Ci::Reports::TestSuite
- Inherits:
-
Object
- Object
- Gitlab::Ci::Reports::TestSuite
- Defined in:
- lib/gitlab/ci/reports/test_suite.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#suite_error ⇒ Object
readonly
Returns the value of attribute suite_error.
-
#test_cases ⇒ Object
Returns the value of attribute test_cases.
-
#total_time ⇒ Object
Returns the value of attribute total_time.
Instance Method Summary collapse
- #+(other) ⇒ Object
- #add_test_case(test_case) ⇒ Object
- #each_test_case ⇒ Object
-
#initialize(name = nil) ⇒ TestSuite
constructor
A new instance of TestSuite.
- #set_suite_error(msg) ⇒ Object
- #sorted ⇒ Object
-
#total_count ⇒ Object
rubocop: disable CodeReuse/ActiveRecord.
-
#total_status ⇒ Object
rubocop: enable CodeReuse/ActiveRecord.
- #with_attachment! ⇒ Object
Constructor Details
#initialize(name = nil) ⇒ TestSuite
Returns a new instance of TestSuite.
12 13 14 15 16 |
# File 'lib/gitlab/ci/reports/test_suite.rb', line 12 def initialize(name = nil) @name = name @test_cases = {} @total_time = 0.0 end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
7 8 9 |
# File 'lib/gitlab/ci/reports/test_suite.rb', line 7 def name @name end |
#suite_error ⇒ Object (readonly)
Returns the value of attribute suite_error.
10 11 12 |
# File 'lib/gitlab/ci/reports/test_suite.rb', line 10 def suite_error @suite_error end |
#test_cases ⇒ Object
Returns the value of attribute test_cases.
8 9 10 |
# File 'lib/gitlab/ci/reports/test_suite.rb', line 8 def test_cases @test_cases end |
#total_time ⇒ Object
Returns the value of attribute total_time.
9 10 11 |
# File 'lib/gitlab/ci/reports/test_suite.rb', line 9 def total_time @total_time end |
Instance Method Details
#+(other) ⇒ Object
78 79 80 81 82 83 84 |
# File 'lib/gitlab/ci/reports/test_suite.rb', line 78 def +(other) self.class.new.tap do |test_suite| test_suite.name = other.name test_suite.test_cases = self.test_cases.deep_merge(other.test_cases) test_suite.total_time = self.total_time + other.total_time end end |
#add_test_case(test_case) ⇒ Object
18 19 20 21 22 |
# File 'lib/gitlab/ci/reports/test_suite.rb', line 18 def add_test_case(test_case) @test_cases[test_case.status] ||= {} @test_cases[test_case.status][test_case.key] = test_case @total_time += test_case.execution_time end |
#each_test_case ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/gitlab/ci/reports/test_suite.rb', line 24 def each_test_case @test_cases.each do |status, test_cases| test_cases.values.each do |test_case| yield test_case end end end |
#set_suite_error(msg) ⇒ Object
74 75 76 |
# File 'lib/gitlab/ci/reports/test_suite.rb', line 74 def set_suite_error(msg) @suite_error = msg end |
#sorted ⇒ Object
86 87 88 89 90 |
# File 'lib/gitlab/ci/reports/test_suite.rb', line 86 def sorted sort_by_status sort_by_execution_time_desc self end |
#total_count ⇒ Object
rubocop: disable CodeReuse/ActiveRecord
33 34 35 36 37 |
# File 'lib/gitlab/ci/reports/test_suite.rb', line 33 def total_count return 0 if suite_error [success_count, failed_count, skipped_count, error_count].sum end |
#total_status ⇒ Object
rubocop: enable CodeReuse/ActiveRecord
40 41 42 43 44 45 46 47 48 |
# File 'lib/gitlab/ci/reports/test_suite.rb', line 40 def total_status if suite_error TestCase::STATUS_ERROR elsif failed_count > 0 || error_count > 0 TestCase::STATUS_FAILED else TestCase::STATUS_SUCCESS end end |
#with_attachment! ⇒ Object
50 51 52 53 54 55 56 57 58 |
# File 'lib/gitlab/ci/reports/test_suite.rb', line 50 def @test_cases = @test_cases.extract!("failed") @test_cases.keep_if do |status, hash| hash.any? do |key, test_case| test_case. end end end |