Class: Fastlane::Helper::AwsDeviceFarmHelper
- Inherits:
-
Object
- Object
- Fastlane::Helper::AwsDeviceFarmHelper
- Defined in:
- lib/fastlane/plugin/aws_device_farm/helper/aws_device_farm_helper.rb
Class Method Summary collapse
-
.create_junit_xml(test_results:, file_path:, file_prefix:) ⇒ Object
create Junit.xml.
-
.get_artifact(url:, file_dir_path:, file_name:) ⇒ Object
get Artifact.
Class Method Details
.create_junit_xml(test_results:, file_path:, file_prefix:) ⇒ Object
create Junit.xml
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 |
# File 'lib/fastlane/plugin/aws_device_farm/helper/aws_device_farm_helper.rb', line 10 def self.create_junit_xml(test_results:, file_path:, file_prefix:) doc = REXML::Document.new doc << REXML::XMLDecl.new('1.0', 'UTF-8') # test_suites root = REXML::Element.new('testsuites') root.add_attribute('name', "#{test_results['name']}") root.add_attribute('tests', "#{test_results['tests']}") root.add_attribute('failures', "#{test_results['failures']}") root.add_attribute('time', "#{test_results['time']}") doc.add_element(root) test_results['test_suites'].each do |suite| testsuite = REXML::Element.new('testsuite') testsuite.add_attribute('name', "#{suite['name']}") testsuite.add_attribute('tests', "#{suite['tests']}") testsuite.add_attribute('errors', "#{suite['errors']}") testsuite.add_attribute('failures', "#{suite['failures']}") testsuite.add_attribute('time', "#{suite['time']}") root.add_element(testsuite) suite['test_lists'].each do |test| testcase = REXML::Element.new('testcase') testcase.add_attribute('classname', "#{test['class_name']}") testcase.add_attribute('name', "#{test['name']}") testcase.add_attribute('time', "#{test['time']}") testsuite.add_element(testcase) end end # output file_name = "#{file_prefix}-#{File.basename(file_path)}" file_dir_path = File.dirname(file_path) FileUtils.mkdir_p(file_dir_path) File.open("#{file_dir_path}/#{file_name}", 'w') do |file| doc.write(file, indent=2) end end |
.get_artifact(url:, file_dir_path:, file_name:) ⇒ Object
get Artifact
51 52 53 54 55 56 57 58 59 60 |
# File 'lib/fastlane/plugin/aws_device_farm/helper/aws_device_farm_helper.rb', line 51 def self.get_artifact(url:, file_dir_path:, file_name:) file_path = "#{file_dir_path}/#{file_name}" FileUtils.mkdir_p(File.dirname(file_path)) open(url) do |file| open(file_path, "w+b") do |out| out.write(file.read) end end end |