Class: Fastlane::Actions::TestsFromXcresultAction
- Inherits:
-
Action
- Object
- Action
- Fastlane::Actions::TestsFromXcresultAction
- Defined in:
- lib/fastlane/plugin/test_center/actions/tests_from_xcresult.rb
Documentation collapse
- .authors ⇒ Object
- .available_options ⇒ Object
- .category ⇒ Object
- .description ⇒ Object
- .is_supported?(platform) ⇒ Boolean
- .return_value ⇒ Object
Class Method Summary collapse
Class Method Details
.authors ⇒ Object
90 91 92 |
# File 'lib/fastlane/plugin/test_center/actions/tests_from_xcresult.rb', line 90 def self. ["lyndsey-ferguson/lyndseydf"] end |
.available_options ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/fastlane/plugin/test_center/actions/tests_from_xcresult.rb', line 70 def self. [ FastlaneCore::ConfigItem.new( key: :xcresult, env_name: "FL_TESTS_FROM_XCRESULT_XCRESULT_PATH", description: "The path to the xcresult bundle to retrieve the tests from", verify_block: proc do |path| UI.user_error!("Error: cannot find the xcresult bundle at '#{path}'") unless Dir.exist?(path) UI.user_error!("Error: cannot parse files that are not in the xcresult format") unless File.extname(path) == ".xcresult" end ) ] end |
.category ⇒ Object
94 95 96 |
# File 'lib/fastlane/plugin/test_center/actions/tests_from_xcresult.rb', line 94 def self.category :testing end |
.description ⇒ Object
65 66 67 |
# File 'lib/fastlane/plugin/test_center/actions/tests_from_xcresult.rb', line 65 def self.description "☑️ Retrieves the failing and passing tests as reportedn an xcresult bundle" end |
.is_supported?(platform) ⇒ Boolean
98 99 100 |
# File 'lib/fastlane/plugin/test_center/actions/tests_from_xcresult.rb', line 98 def self.is_supported?(platform) i[ios mac].include?(platform) end |
.return_value ⇒ Object
84 85 86 87 88 |
# File 'lib/fastlane/plugin/test_center/actions/tests_from_xcresult.rb', line 84 def self.return_value "A Hash with information about the test results:\r\n" \ "failed: an Array of the failed test identifiers\r\n" \ "passing: an Array of the passing test identifiers\r\n" end |
.run(params) ⇒ Object
7 8 9 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 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/fastlane/plugin/test_center/actions/tests_from_xcresult.rb', line 7 def self.run(params) unless FastlaneCore::Helper.xcode_at_least?('11.0.0') UI.error("Error: tests_from_xcresult requires at least Xcode 11.0") return {} end xcresult_path = File.absolute_path(params[:xcresult]) # taken from the rubygem trainer, in the test_parser.rb module result_bundle_object_raw = sh("xcrun xcresulttool get --path #{xcresult_path.shellescape} --format json", print_command: false, print_command_output: false) result_bundle_object = JSON.parse(result_bundle_object_raw) # Parses JSON into ActionsInvocationRecord to find a list of all ids for ActionTestPlanRunSummaries actions_invocation_record = Trainer::XCResult::ActionsInvocationRecord.new(result_bundle_object) test_refs = actions_invocation_record.actions.map do |action| action.action_result.tests_ref end.compact ids = test_refs.map(&:id) summaries = ids.map do |id| raw = sh("xcrun xcresulttool get --format json --path #{xcresult_path.shellescape} --id #{id}", print_command: false, print_command_output: false) json = JSON.parse(raw) Trainer::XCResult::ActionTestPlanRunSummaries.new(json) end failures = actions_invocation_record.issues.test_failure_summaries || [] all_summaries = summaries.map(&:summaries).flatten testable_summaries = all_summaries.map(&:testable_summaries).flatten failed = [] passing = [] failure_details = {} rows = testable_summaries.map do |testable_summary| all_tests = testable_summary.all_tests.flatten all_tests.each do |t| if t.test_status == 'Success' passing << "#{t.parent.name}/#{t.identifier}" else test_identifier = "#{t.parent.name}/#{t.identifier}" failed << test_identifier failure = t.find_failure(failures) if failure failure_details[test_identifier] = { message: failure. } end end end end { failed: failed.uniq, passing: passing.uniq, failure_details: failure_details } end |