class XCResult::ActionTestMetadata

Attributes

activity_summaries_count[RW]
duration[RW]
failure_summaries_count[RW]
performance_metrics_count[RW]
summary_ref[RW]
test_status[RW]

Public Class Methods

new(data, parent) click to toggle source
# 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

Public Instance Methods

all_subtests() click to toggle source
# File lib/xcresult/models.rb, line 180
def all_subtests
  [self]
end
find_failure(failures) click to toggle source
# 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