fastlane-plugin-xcresult_to_junit 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1532fc3a5078d597ebdbb5e41a5bd038f38d9e3481ffe0b22b4dca0766f0a079
|
4
|
+
data.tar.gz: 81d441aec6f1bf6c8b0034a54f569fdf6164bc74c0533db42bbc51daf0503d84
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e69e4ee036d1ad1158438cd65f01fc0fe04b5284a1dc57510a85b73744add7014dbaf141f44f6291510bfbdc166133bd7896a82a226cfc23dd6cbbaa74211627
|
7
|
+
data.tar.gz: 77e4e345da4c1b667805f9e1c66fb0db02fc96c412b04c417651a60aab0ae68df28201ec2964dd7fd691fb56d35e804f6dc472e995afb58b079475bdda1469cc
|
data/README.md
CHANGED
@@ -38,7 +38,7 @@ Ensure you specify the following when you call scan
|
|
38
38
|
|
39
39
|
After scan you can call the plugin, which will look something like this
|
40
40
|
```ruby
|
41
|
-
xcresult_to_junit(xcresult_path: './test_output/MyScheme.test_result.xcresult', output_path: './test_output/')
|
41
|
+
xcresult_to_junit(xcresult_path: './fastlane/test_output/MyScheme.test_result.xcresult', output_path: './fastlane/test_output/')
|
42
42
|
```
|
43
43
|
|
44
44
|
We can get a list of the junit reports generated by doing something like so
|
@@ -9,6 +9,7 @@ module Fastlane
|
|
9
9
|
all_results = Helper::XcresultToJunitHelper.load_results(params[:xcresult_path])['actions']['_values']
|
10
10
|
all_results.each do |test_run|
|
11
11
|
if test_run['actionResult']['testsRef'] # Skip if section has no testRef data as this means its not a test run
|
12
|
+
junit_folder = Helper::XcresultToJunitHelper.save_device_details_to_file(params[:output_path], test_run['runDestination'])
|
12
13
|
test_run_id = test_run['actionResult']['testsRef']['id']['_value']
|
13
14
|
all_tests = Helper::XcresultToJunitHelper.load_object(params[:xcresult_path], test_run_id)['summaries']['_values'][0]['testableSummaries']['_values']
|
14
15
|
test_suites = []
|
@@ -21,12 +22,26 @@ module Fastlane
|
|
21
22
|
end
|
22
23
|
test_classes = target['tests']['_values'][0]['subtests']['_values'][0]['subtests']['_values']
|
23
24
|
test_classes.each do |test_class|
|
24
|
-
|
25
|
+
suite_name = "#{target_name}.#{test_class['name']['_value']}"
|
26
|
+
suite = { name: suite_name, cases: [] }
|
25
27
|
if test_class['subtests']
|
26
28
|
test_class['subtests']['_values'].each do |test|
|
27
29
|
duration = 0
|
28
30
|
duration = test['duration']['_value'] if test['duration']
|
29
|
-
|
31
|
+
testcase_name = test['name']['_value'].tr('()', '')
|
32
|
+
testcase = { name: testcase_name, time: duration }
|
33
|
+
|
34
|
+
summaryRef = test['summaryRef']['id']['_value']
|
35
|
+
ref = Helper::XcresultToJunitHelper.load_object(params[:xcresult_path], summaryRef)['activitySummaries']['_values']
|
36
|
+
ref.each do |summary|
|
37
|
+
if summary['attachments']
|
38
|
+
summary['attachments']['_values'].each do |attachment|
|
39
|
+
id = attachment['payloadRef']['id']['_value']
|
40
|
+
Helper::XcresultToJunitHelper.fetch_screenshot(params[:xcresult_path], "#{junit_folder}/attachments/#{suite_name}.#{testcase_name}", "#{id}.png", id)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
30
45
|
if test['testStatus']['_value'] == 'Failure'
|
31
46
|
failure = Helper::XcresultToJunitHelper.load_object(params[:xcresult_path], test['summaryRef']['id']['_value'])['failureSummaries']['_values'][0]
|
32
47
|
filename = failure['fileName']['_value']
|
@@ -47,7 +62,6 @@ module Fastlane
|
|
47
62
|
test_suites << suite
|
48
63
|
end
|
49
64
|
end
|
50
|
-
junit_folder = Helper::XcresultToJunitHelper.save_device_details_to_file(params[:output_path], test_run['runDestination'])
|
51
65
|
Helper::XcresultToJunitHelper.generate_junit(junit_folder, test_suites)
|
52
66
|
end
|
53
67
|
end
|
@@ -15,6 +15,13 @@ module Fastlane
|
|
15
15
|
JSON.load FastlaneCore::CommandExecutor.execute(command: "xcrun xcresulttool get --format json --path #{xcresult_path}")
|
16
16
|
end
|
17
17
|
|
18
|
+
def self.fetch_screenshot(xcresult_path, output_path, file_name, id)
|
19
|
+
if !File.directory?(output_path)
|
20
|
+
FileUtils.mkdir output_path
|
21
|
+
end
|
22
|
+
JSON.load FastlaneCore::CommandExecutor.execute(command: "xcrun xcresulttool export --path #{xcresult_path} --output-path #{output_path}/#{file_name} --id #{id} --type file")
|
23
|
+
end
|
24
|
+
|
18
25
|
def self.save_device_details_to_file(output_path, device_destination)
|
19
26
|
device_udid = device_destination['targetDeviceRecord']['identifier']['_value']
|
20
27
|
device_details = {
|
@@ -26,6 +33,7 @@ module Fastlane
|
|
26
33
|
junit_folder = "#{output_path}/ios-#{device_udid}.junit"
|
27
34
|
FileUtils.rm_rf junit_folder
|
28
35
|
FileUtils.mkdir junit_folder
|
36
|
+
FileUtils.mkdir "#{junit_folder}/attachments"
|
29
37
|
File.open("#{junit_folder}/device.json", 'w') do |f|
|
30
38
|
f << device_details
|
31
39
|
end
|
@@ -55,7 +63,7 @@ module Fastlane
|
|
55
63
|
end
|
56
64
|
|
57
65
|
def self.junit_testcase_start(suite, testcase)
|
58
|
-
print "<testcase
|
66
|
+
print "<testcase name=#{testcase[:name].encode xml: :attr} classname=#{suite[:name].encode xml: :attr} time='#{testcase[:time]}'"
|
59
67
|
end
|
60
68
|
|
61
69
|
def self.junit_testcase_success
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fastlane-plugin-xcresult_to_junit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shane Birdsall
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-11-
|
11
|
+
date: 2019-11-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pry
|