class Fastlane::Actions::XcodebuildonlytestingAction

Public Class Methods

authors() click to toggle source
# File lib/fastlane/plugin/xcodebuildonlytesting/actions/xcodebuildonlytesting_action.rb, line 45
def self.authors
  ["Luís Esteves"]
end
available_options() click to toggle source
# File lib/fastlane/plugin/xcodebuildonlytesting/actions/xcodebuildonlytesting_action.rb, line 58
def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :reportLocation,
                                 description: "junit report location",
                                 optional: false),
  ]
end
description() click to toggle source
# File lib/fastlane/plugin/xcodebuildonlytesting/actions/xcodebuildonlytesting_action.rb, line 41
def self.description
  "Creates a array of tests from a junit to feed the xcodebuild only-testing"
end
details() click to toggle source
# File lib/fastlane/plugin/xcodebuildonlytesting/actions/xcodebuildonlytesting_action.rb, line 53
def self.details
  # Optional:
  "Creates a array of tests from a junit to feed the xcodebuild only-testing"
end
is_supported?(platform) click to toggle source
# File lib/fastlane/plugin/xcodebuildonlytesting/actions/xcodebuildonlytesting_action.rb, line 66
def self.is_supported?(platform)
  platform == :ios
end
return_value() click to toggle source
# File lib/fastlane/plugin/xcodebuildonlytesting/actions/xcodebuildonlytesting_action.rb, line 49
def self.return_value
  # If your method provides a return value, you can describe here what it does
end
run(params) click to toggle source
# File lib/fastlane/plugin/xcodebuildonlytesting/actions/xcodebuildonlytesting_action.rb, line 7
def self.run(params)
  UI.message("The xcodebuildonlytesting plugin is working!")

  report_file = File.open(params[:reportLocation]) { |f| REXML::Document.new(f) }

  FastlaneCore::UI.user_error!("Malformed XML test report file given") if report_file.root.nil?
  FastlaneCore::UI.user_error!("Valid XML file is not an Xcode test report") if report_file.get_elements('testsuites').empty?

  failingTests = []
  report_file.elements.each('testsuites') do |testsuites_element|
    
    testsuites_element.elements.each('testsuite') do |testsuite_element|
      testsuiteName = testsuite_element.attribute('name').value
      UI.message("testsuite: #{testsuiteName}".green)
      
      testsuite_element.elements.each('testcase') do |testcase_element|
        className = testcase_element.attribute('classname').value
        testName = testcase_element.attribute('name').value
        testName.slice!('()')

        failure = testcase_element.elements['failure']
        if failure 
          UI.message(" NOK: #{className} - #{testName}".red)
          failingTests << "#{testsuiteName}/#{className}/#{testName}"
        else
          UI.message(" OK: #{className} - #{testName}".green)
        end
      end
    end
  end
  
  return failingTests
end