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.



170
171
172
173
174
175
176
177
178
# File 'lib/xcresult/models.rb', line 170

def initialize(data, parent)
  self.test_status = fetch_value(data, 'testStatus')
  self.duration = fetch_value(data, 'duration').to_f
  self.summary_ref = Reference.new(data['summaryRef']) if data['summaryRef']
  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.



169
170
171
# File 'lib/xcresult/models.rb', line 169

def activity_summaries_count
  @activity_summaries_count
end

#durationObject

Returns the value of attribute duration.



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

def duration
  @duration
end

#failure_summaries_countObject

Returns the value of attribute failure_summaries_count.



168
169
170
# File 'lib/xcresult/models.rb', line 168

def failure_summaries_count
  @failure_summaries_count
end

#performance_metrics_countObject

Returns the value of attribute performance_metrics_count.



167
168
169
# File 'lib/xcresult/models.rb', line 167

def performance_metrics_count
  @performance_metrics_count
end

#summary_refObject

Returns the value of attribute summary_ref.



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

def summary_ref
  @summary_ref
end

#test_statusObject

Returns the value of attribute test_status.



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

def test_status
  @test_status
end

Instance Method Details

#all_subtestsObject



180
181
182
# File 'lib/xcresult/models.rb', line 180

def all_subtests
  [self]
end

#find_failure(failures) ⇒ Object



184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
# File 'lib/xcresult/models.rb', line 184

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