Class: Trainer::XCResult::ActionTestMetadata

Inherits:
ActionTestSummaryIdentifiableObject show all
Defined in:
trainer/lib/trainer/xcresult.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.



162
163
164
165
166
167
168
169
# File 'trainer/lib/trainer/xcresult.rb', line 162

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.



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

def activity_summaries_count
  @activity_summaries_count
end

#durationObject

Returns the value of attribute duration.



158
159
160
# File 'trainer/lib/trainer/xcresult.rb', line 158

def duration
  @duration
end

#failure_summaries_countObject

Returns the value of attribute failure_summaries_count.



160
161
162
# File 'trainer/lib/trainer/xcresult.rb', line 160

def failure_summaries_count
  @failure_summaries_count
end

#performance_metrics_countObject

Returns the value of attribute performance_metrics_count.



159
160
161
# File 'trainer/lib/trainer/xcresult.rb', line 159

def performance_metrics_count
  @performance_metrics_count
end

#test_statusObject

Returns the value of attribute test_status.



157
158
159
# File 'trainer/lib/trainer/xcresult.rb', line 157

def test_status
  @test_status
end

Instance Method Details

#all_subtestsObject



171
172
173
# File 'trainer/lib/trainer/xcresult.rb', line 171

def all_subtests
  return [self]
end

#find_failure(failures) ⇒ Object



175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
# File 'trainer/lib/trainer/xcresult.rb', line 175

def find_failure(failures)
  sanitizer = proc { |name| name.gsub(/\W/, "_") }
  sanitized_identifier = sanitizer.call(self.identifier)
  if self.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|
      # Sanitize both test case name and identifier in a consistent fashion, then replace all non-word
      # chars with underscore, and compare them
      sanitized_test_case_name = sanitizer.call(failure.test_case_name)
      sanitized_identifier == sanitized_test_case_name
    end
    return found_failure
  else
    return nil
  end
end