@@ -78,30 +78,34 @@ def export_screenshots(options = XCResult::ExportOptions.new(destination: Dir.pw
7878      # Iterate through each action as it represents run destination (testing device) 
7979      actions . each  do  |action |
8080        action_test_plan_run_summaries  =  action . action_result . tests_ref . load_object ( from : path ) 
81-         action_testable_summaries  =  action_test_plan_run_summaries . summaries . flat_map ( &:testable_summaries ) 
82- 
83-         # Iterate thorugh each action_testable_summary as it represents testing conditions such as region and language 
84-         action_testable_summaries . each  do  |action_testable_summary |
85-           # Collect all attachments from a testing condition 
86-           attachments  =  action_testable_summary . all_tests 
87-                                                . map ( &:summary_ref ) 
88-                                                . map  {  |ref | ref . load_object ( from : path )  } 
89-                                                . flat_map ( &:activity_summaries ) 
90-                                                . flat_map ( &:subactivities ) 
91-                                                . flat_map ( &:attachments ) 
92- 
93-           # Prepare output directory for each tests 
94-           output_directory  =  options . output_directory ( 
95-             target_device_record : action . run_destination . target_device_record , 
96-             action_testable_summary : action_testable_summary 
97-           ) 
98-           FileUtils . mkdir_p ( output_directory )  unless  Dir . exist? ( output_directory ) 
99- 
100-           # Finally exports attachments 
101-           attachments . each  do  |attachment |
102-             output_path  =  File . join ( output_directory ,  attachment . filename ) 
103-             cmd  =  "xcrun xcresulttool export --path #{ path }   --id '#{ attachment . payload_ref . id }  ' --output-path '#{ output_path }  ' --type file" 
104-             execute_cmd ( cmd ) 
81+         action_test_plan_summaries  =  action_test_plan_run_summaries . summaries 
82+ 
83+         # Iterate thorugh each action_test_plan_summaries as it represents test name 
84+         action_test_plan_summaries . each  do  |action_test_plan_summary |
85+           # Iterate thorugh each action_testable_summary as it represents testing conditions such as region and language 
86+           action_test_plan_summary . testable_summaries . each  do  |action_testable_summary |
87+             # Collect all attachments from a testing condition 
88+             attachments  =  action_testable_summary . all_tests 
89+                                                  . map ( &:summary_ref ) 
90+                                                  . map  {  |ref | ref . load_object ( from : path )  } 
91+                                                  . flat_map ( &:activity_summaries ) 
92+                                                  . flat_map ( &:subactivities ) 
93+                                                  . flat_map ( &:attachments ) 
94+ 
95+             # Prepare output directory for each tests 
96+             output_directory  =  options . output_directory ( 
97+               target_device_record : action . run_destination . target_device_record , 
98+               action_test_plan_summary : action_test_plan_summary , 
99+               action_testable_summary : action_testable_summary 
100+             ) 
101+             FileUtils . mkdir_p ( output_directory )  unless  Dir . exist? ( output_directory ) 
102+ 
103+             # Finally exports attachments 
104+             attachments . each  do  |attachment |
105+               output_path  =  File . join ( output_directory ,  attachment . filename ) 
106+               cmd  =  "xcrun xcresulttool export --path #{ path }   --id '#{ attachment . payload_ref . id }  ' --output-path '#{ output_path }  ' --type file" 
107+               execute_cmd ( cmd ) 
108+             end 
105109          end 
106110        end 
107111      end 
0 commit comments