Class: Fastlane::Actions::MultiScanAction
- Inherits:
-
Action
- Object
- Action
- Fastlane::Actions::MultiScanAction
- Defined in:
- lib/fastlane/plugin/retry_failed_tests/actions/multi_scan.rb
Documentation collapse
- .authors ⇒ Object
- .available_options ⇒ Object
- .description ⇒ Object
- .details ⇒ Object
- .is_supported?(platform) ⇒ Boolean
- .scan_options ⇒ Object
Class Method Summary collapse
-
.config_with_retry(config, count) ⇒ Object
Create scan config.
-
.get_folder_root(folder) ⇒ Object
Get folder location.
-
.merge_reports(scan_options, final_report_path) ⇒ Object
Merge results from all retries.
-
.parse_failures(plist) ⇒ Object
Parse the names of the failed test cases.
- .run(params) ⇒ Object
Class Method Details
.authors ⇒ Object
109 110 111 |
# File 'lib/fastlane/plugin/retry_failed_tests/actions/multi_scan.rb', line 109 def self. ["Gloria Chow/@gmgchow"] end |
.available_options ⇒ Object
96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/fastlane/plugin/retry_failed_tests/actions/multi_scan.rb', line 96 def self. + [ FastlaneCore::ConfigItem.new( key: :try_count, env_name: "FL_MULTI_SCAN_TRY_COUNT", description: "The number of times to retry running tests via scan", type: Integer, is_string: false, default_value: 1 ) ] end |
.config_with_retry(config, count) ⇒ Object
Create scan config
67 68 69 70 71 72 |
# File 'lib/fastlane/plugin/retry_failed_tests/actions/multi_scan.rb', line 67 def self.config_with_retry(config, count) folder = get_folder_root(config[:result_bundle]) config[:result_bundle] = (folder + count.to_s) config[:output_directory] = (folder + count.to_s) config end |
.description ⇒ Object
84 85 86 |
# File 'lib/fastlane/plugin/retry_failed_tests/actions/multi_scan.rb', line 84 def self.description "Uses scan to run Xcode tests a given number of times: only re-testing failing tests." end |
.details ⇒ Object
88 89 90 |
# File 'lib/fastlane/plugin/retry_failed_tests/actions/multi_scan.rb', line 88 def self.details "Use this action to run your tests if you have fragile tests that fail sporadically." end |
.get_folder_root(folder) ⇒ Object
Get folder location
75 76 77 78 |
# File 'lib/fastlane/plugin/retry_failed_tests/actions/multi_scan.rb', line 75 def self.get_folder_root(folder) folder = folder.gsub(/ *\d+$/, '') folder end |
.is_supported?(platform) ⇒ Boolean
113 114 115 |
# File 'lib/fastlane/plugin/retry_failed_tests/actions/multi_scan.rb', line 113 def self.is_supported?(platform) platform == :ios end |
.merge_reports(scan_options, final_report_path) ⇒ Object
Merge results from all retries
51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/fastlane/plugin/retry_failed_tests/actions/multi_scan.rb', line 51 def self.merge_reports(, final_report_path) folder = get_folder_root([:output_directory]) report_files = Dir.glob("#{folder}*/MercariUITests.test_result/1_Test/action_TestSummaries.plist") asset_files = Dir.glob("#{folder}*/MercariUITests.test_result/1_Test/Attachments") log_files = Dir.glob("#{folder}*/MercariUITests.test_result/1_Test/action.xcactivitylog") if report_files.size > 1 other_action.collate_junit_reports( reports: report_files, collated_report: final_report_path, assets: asset_files, logs: log_files, ) end end |
.parse_failures(plist) ⇒ Object
Parse the names of the failed test cases
40 41 42 43 44 45 46 47 48 |
# File 'lib/fastlane/plugin/retry_failed_tests/actions/multi_scan.rb', line 40 def self.parse_failures(plist) failures = Array.new target_report = File.open(plist) {|f| Nokogiri::XML(f)} failed = target_report.xpath("//key[contains(.,'Failure')]/../key[contains(.,'TestIdentifier')]/following-sibling::string[contains(.,'()') and contains (., '/')]") failed.each do |test_name| failures << ("MercariUITests/" + test_name.to_s.split('(')[0].split('>')[1]) end failures end |
.run(params) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/fastlane/plugin/retry_failed_tests/actions/multi_scan.rb', line 10 def self.run(params) try_count = 0 = params.values.reject { |k| k == :try_count } final_report_path = [:result_bundle] unless Helper.test? FastlaneCore::PrintTable.print_values( config: params._values.reject { |k, v| .key?(k) }, title: "Summary for multi_scan" ) end = config_with_junit_report() begin try_count += 1 = config_with_retry(, try_count) config = FastlaneCore::Configuration.create(Fastlane::Actions::ScanAction., ) Fastlane::Actions::ScanAction.run(config) rescue FastlaneCore::Interface::FastlaneTestFailure => e UI.verbose("Scan failed with #{e}") if try_count < params[:try_count] report_filepath = junit_report_filepath() failed_tests = parse_failures(report_filepath) [:only_testing] = failed_tests retry end end merge_reports(, final_report_path) end |
.scan_options ⇒ Object
92 93 94 |
# File 'lib/fastlane/plugin/retry_failed_tests/actions/multi_scan.rb', line 92 def self. ScanAction. end |