Class: XCResult::ActionTestMetadata

Inherits:
ActionTestSummaryIdentifiableObject show all
Defined in:
lib/xcresult/models.rb

Overview

  • ActionTestMetadata

    • Supertype: ActionTestSummaryIdentifiableObject

    • Kind: object

    • Properties: + testStatus: String + duration: Double? + summaryRef: Reference? + performanceMetricsCount: Int + failureSummariesCount: Int + activitySummariesCount: Int

Instance Attribute Summary collapse

Attributes inherited from ActionTestSummaryIdentifiableObject

#identifier, #parent

Attributes inherited from ActionAbstractTestSummary

#name

Attributes inherited from AbstractObject

#type

Instance Method Summary collapse

Methods inherited from ActionTestSummaryIdentifiableObject

create

Methods inherited from AbstractObject

#fetch_value, #fetch_values

Constructor Details

#initialize(data, parent) ⇒ ActionTestMetadata

Returns a new instance of ActionTestMetadata.



166
167
168
169
170
171
172
173
# File 'lib/xcresult/models.rb', line 166

def initialize(data, parent)
  self.test_status = fetch_value(data, 'testStatus')
  self.duration = fetch_value(data, 'duration').to_f
  self.performance_metrics_count = fetch_value(data, 'performanceMetricsCount')
  self.failure_summaries_count = fetch_value(data, 'failureSummariesCount')
  self.activity_summaries_count = fetch_value(data, 'activitySummariesCount')
  super(data, parent)
end

Instance Attribute Details

#activity_summaries_countObject

Returns the value of attribute activity_summaries_count.



165
166
167
# File 'lib/xcresult/models.rb', line 165

def activity_summaries_count
  @activity_summaries_count
end

#durationObject

Returns the value of attribute duration.



162
163
164
# File 'lib/xcresult/models.rb', line 162

def duration
  @duration
end

#failure_summaries_countObject

Returns the value of attribute failure_summaries_count.



164
165
166
# File 'lib/xcresult/models.rb', line 164

def failure_summaries_count
  @failure_summaries_count
end

#performance_metrics_countObject

Returns the value of attribute performance_metrics_count.



163
164
165
# File 'lib/xcresult/models.rb', line 163

def performance_metrics_count
  @performance_metrics_count
end

#test_statusObject

Returns the value of attribute test_status.



161
162
163
# File 'lib/xcresult/models.rb', line 161

def test_status
  @test_status
end

Instance Method Details

#all_subtestsObject



175
176
177
# File 'lib/xcresult/models.rb', line 175

def all_subtests
  [self]
end

#find_failure(failures) ⇒ Object



179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
# File 'lib/xcresult/models.rb', line 179

def find_failure(failures)
  if test_status == 'Failure'
    # Tries to match failure on test case name
    # Example TestFailureIssueSummary:
    #   producingTarget: "TestThisDude"
    #   test_case_name: "TestThisDude.testFailureJosh2()" (when Swift)
    #     or "-[TestThisDudeTests testFailureJosh2]" (when Objective-C)
    # Example ActionTestMetadata
    #   identifier: "TestThisDude/testFailureJosh2()" (when Swift)
    #     or identifier: "TestThisDude/testFailureJosh2" (when Objective-C)

    found_failure = failures.find do |failure|
      # Clean test_case_name to match identifier format
      # Sanitize for Swift by replacing "." for "/"
      # Sanitize for Objective-C by removing "-", "[", "]", and replacing " " for ?/
      sanitized_test_case_name = failure.test_case_name
                                        .tr('.', '/')
                                        .tr('-', '')
                                        .tr('[', '')
                                        .tr(']', '')
                                        .tr(' ', '/')
      identifier == sanitized_test_case_name
    end
    found_failure
  end
end