Class: Fastlane::Actions::TestsFromXctestrunAction

Inherits:
Action
  • Object
show all
Defined in:
lib/fastlane/plugin/test_center/actions/tests_from_xctestrun.rb

Documentation collapse

Class Method Summary collapse

Class Method Details

.authorsObject



56
57
58
# File 'lib/fastlane/plugin/test_center/actions/tests_from_xctestrun.rb', line 56

def self.authors
  ["lyndsey-ferguson/lyndseydf"]
end

.available_optionsObject



39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/fastlane/plugin/test_center/actions/tests_from_xctestrun.rb', line 39

def self.available_options
  [
    FastlaneCore::ConfigItem.new(
      key: :xctestrun,
      env_name: "FL_SUPPRESS_TESTS_FROM_XCTESTRUN_FILE",
      description: "The xctestrun file to use to find where the xctest bundle file is for test retrieval",
      verify_block: proc do |path|
        UI.user_error!("Error: cannot find the xctestrun file '#{path}'") unless File.exist?(path)
      end
    )
  ]
end

.descriptionObject



35
36
37
# File 'lib/fastlane/plugin/test_center/actions/tests_from_xctestrun.rb', line 35

def self.description
  "Retrieves all of the tests from xctest bundles referenced by the xctestrun file"
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


60
61
62
# File 'lib/fastlane/plugin/test_center/actions/tests_from_xctestrun.rb', line 60

def self.is_supported?(platform)
  platform == :ios
end

.return_valueObject



52
53
54
# File 'lib/fastlane/plugin/test_center/actions/tests_from_xctestrun.rb', line 52

def self.return_value
  "A Hash of testable => tests, where testable is the name of the test target and tests is an array of test identifiers"
end

.run(params) ⇒ Object



6
7
8
# File 'lib/fastlane/plugin/test_center/actions/tests_from_xctestrun.rb', line 6

def self.run(params)
  return xctestrun_tests(params[:xctestrun])
end

.xctest_bundle_path(xctestrun_rootpath, xctestrun_config) ⇒ Object



26
27
28
29
# File 'lib/fastlane/plugin/test_center/actions/tests_from_xctestrun.rb', line 26

def self.xctest_bundle_path(xctestrun_rootpath, xctestrun_config)
  xctest_host_path = xctestrun_config['TestHostPath'].sub('__TESTROOT__', xctestrun_rootpath)
  xctestrun_config['TestBundlePath'].sub('__TESTHOST__', xctest_host_path).sub('__TESTROOT__', xctestrun_rootpath)
end

.xctestrun_tests(xctestrun_path) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/fastlane/plugin/test_center/actions/tests_from_xctestrun.rb', line 10

def self.xctestrun_tests(xctestrun_path)
  xctestrun = Plist.parse_xml(xctestrun_path)
  xctestrun_rootpath = File.dirname(xctestrun_path)
  tests = Hash.new([])
  xctestrun.each do |testable_name, xctestrun_config|
    test_identifiers = XCTestList.tests(xctest_bundle_path(xctestrun_rootpath, xctestrun_config))
    if xctestrun_config.key?('SkipTestIdentifiers')
      test_identifiers.reject! { |test_identifier| xctestrun_config['SkipTestIdentifiers'].include?(test_identifier) }
    end
    tests[testable_name] = test_identifiers.map do |test_identifier|
      "#{testable_name.shellescape}/#{test_identifier}"
    end
  end
  tests
end