Class: Fastlane::Helper::RescanFlakyTestsHelper

Inherits:
Object
  • Object
show all
Defined in:
lib/fastlane/plugin/rescan_flaky_tests/helper/rescan_flaky_tests_helper.rb

Class Method Summary collapse

Class Method Details

.extract_failed_test_cases(report_file) ⇒ Object

class methods that you define here become available in your action as ‘Helper::RescanEachFragileTestsHelper.your_method`



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/fastlane/plugin/rescan_flaky_tests/helper/rescan_flaky_tests_helper.rb', line 9

def self.extract_failed_test_cases(report_file)
  xml_doc = REXML::Document.new(File.open(report_file))

  if xml_doc.elements.collect("testsuites") { |e| e }.count == 0
    return nil
  end

  test_cases = []
  xml_doc.elements.each("testsuites/testsuite/testcase[failure]") do |test_case|
    (bundle, test_suite) = test_case.attributes["classname"].split(".")
    method = test_case.attributes["name"]
    # xcodebuild changes '-' to '_'
    bundle.gsub!("_", "-")
    test_cases << "#{bundle}/#{test_suite}/#{method}"
  end
  test_cases
end