class Fastlane::Actions::RunTestsAction
Public Class Methods
available_options()
click to toggle source
# File fastlane/lib/fastlane/actions/run_tests.rb, line 61 def self.available_options require 'scan' FastlaneCore::CommanderGenerator.new.generate(Scan::Options.available_options) + [ FastlaneCore::ConfigItem.new(key: :fail_build, env_name: "SCAN_FAIL_BUILD", description: "Should this step stop the build if the tests fail? Set this to false if you're using trainer", is_string: false, default_value: true) ] end
description()
click to toggle source
# File fastlane/lib/fastlane/actions/run_tests.rb, line 49 def self.description "Easily run tests of your iOS app (via _scan_)" end
details()
click to toggle source
# File fastlane/lib/fastlane/actions/run_tests.rb, line 53 def self.details "More information: https://docs.fastlane.tools/actions/scan/" end
is_supported?(platform)
click to toggle source
# File fastlane/lib/fastlane/actions/run_tests.rb, line 82 def self.is_supported?(platform) [:ios, :mac].include?(platform) end
output()
click to toggle source
# File fastlane/lib/fastlane/actions/run_tests.rb, line 73 def self.output [ ['SCAN_DERIVED_DATA_PATH', 'The path to the derived data'], ['SCAN_GENERATED_PLIST_FILE', 'The generated plist file'], ['SCAN_GENERATED_PLIST_FILES', 'The generated plist files'], ['SCAN_ZIP_BUILD_PRODUCTS_PATH', 'The path to the zipped build products'] ] end
run(values)
click to toggle source
# File fastlane/lib/fastlane/actions/run_tests.rb, line 11 def self.run(values) require 'scan' plist_files_before = [] begin destination = values[:destination] # save destination value which can be later overridden Scan.config = values # we set this here to auto-detect missing values, which we need later on unless values[:derived_data_path].to_s.empty? plist_files_before = test_summary_filenames(values[:derived_data_path]) end values[:destination] = destination # restore destination value Scan::Manager.new.work(values) zip_build_products_path = Scan.cache[:zip_build_products_path] Actions.lane_context[SharedValues::SCAN_ZIP_BUILD_PRODUCTS_PATH] = zip_build_products_path if zip_build_products_path return true rescue FastlaneCore::Interface::FastlaneBuildFailure => ex # Specifically catching FastlaneBuildFailure to prevent build/compile errors from being # silenced when :fail_build is set to false # :fail_build should only suppress testing failures raise ex rescue => ex if values[:fail_build] raise ex end ensure unless values[:derived_data_path].to_s.empty? Actions.lane_context[SharedValues::SCAN_DERIVED_DATA_PATH] = values[:derived_data_path] plist_files_after = test_summary_filenames(values[:derived_data_path]) all_test_summaries = (plist_files_after - plist_files_before) Actions.lane_context[SharedValues::SCAN_GENERATED_PLIST_FILES] = all_test_summaries Actions.lane_context[SharedValues::SCAN_GENERATED_PLIST_FILE] = all_test_summaries.last end end end
Private Class Methods
category()
click to toggle source
# File fastlane/lib/fastlane/actions/run_tests.rb, line 126 def self.category :testing end
example_code()
click to toggle source
# File fastlane/lib/fastlane/actions/run_tests.rb, line 100 def self.example_code [ 'run_tests', 'scan # alias for "run_tests"', 'run_tests( workspace: "App.xcworkspace", scheme: "MyTests", clean: false )', '# Build For Testing run_tests( derived_data_path: "my_folder", build_for_testing: true )', '# run tests using derived data from prev. build run_tests( derived_data_path: "my_folder", test_without_building: true )', '# or run it from an existing xctestrun package run_tests( xctestrun: "/path/to/mytests.xctestrun" )' ] end
test_summary_filenames(derived_data_path)
click to toggle source
# File fastlane/lib/fastlane/actions/run_tests.rb, line 88 def self.test_summary_filenames(derived_data_path) files = [] # Xcode < 10 files += Dir["#{derived_data_path}/**/Logs/Test/*TestSummaries.plist"] # Xcode 10 files += Dir["#{derived_data_path}/**/Logs/Test/*.xcresult/TestSummaries.plist"] return files end