run_tests
Community Action Reference: Inspected directly from Fastlane core ruby gem definitions.
Supported Platforms: ios, mac
Easily run tests of your iOS app (via scan)
Details
More information: https://docs.fastlane.tools/actions/scan/
Parameters & Options
Total options available: 84
| Key | Type | Env Variable | Default | Required | Description |
|---|---|---|---|---|---|
workspace |
String |
SCAN_WORKSPACE |
- |
No | Path to the workspace file |
project |
String |
SCAN_PROJECT |
- |
No | Path to the project file |
package_path |
String |
SCAN_PACKAGE_PATH |
- |
No | Path to the Swift Package |
scheme |
String |
SCAN_SCHEME |
- |
No | The project’s scheme. Make sure it’s marked as Shared |
device |
String |
SCAN_DEVICE |
- |
No | The name of the simulator type you want to run tests on (e.g. ‘iPhone 6’ or ‘iPhone SE (2nd generation) (14.5)’) |
devices |
Array |
SCAN_DEVICES |
- |
No | Array of devices to run the tests on (e.g. [‘iPhone 6’, ‘iPad Air’, ‘iPhone SE (2nd generation) (14.5)’]) |
skip_detect_devices |
Fastlane::Boolean |
- |
false |
No | Should skip auto detecting of devices if none were specified |
ensure_devices_found |
Fastlane::Boolean |
- |
false |
No | Should fail if devices not found |
force_quit_simulator |
Fastlane::Boolean |
SCAN_FORCE_QUIT_SIMULATOR |
false |
Yes | Enabling this option will automatically killall Simulator processes before the run |
reset_simulator |
Fastlane::Boolean |
SCAN_RESET_SIMULATOR |
false |
Yes | Enabling this option will automatically erase the simulator before running the application |
disable_slide_to_type |
Fastlane::Boolean |
SCAN_DISABLE_SLIDE_TO_TYPE |
true |
Yes | Enabling this option will disable the simulator from showing the ‘Slide to type’ prompt |
prelaunch_simulator |
Fastlane::Boolean |
SCAN_PRELAUNCH_SIMULATOR |
- |
No | Enabling this option will launch the first simulator prior to calling any xcodebuild command |
reinstall_app |
Fastlane::Boolean |
SCAN_REINSTALL_APP |
false |
Yes | Enabling this option will automatically uninstall the application before running it |
app_identifier |
String |
SCAN_APP_IDENTIFIER |
- |
No | The bundle identifier of the app to uninstall (only needed when enabling reinstall_app) |
only_testing |
String |
SCAN_ONLY_TESTING |
- |
No | Array of test identifiers to run. Expected format: TestTarget[/TestSuite[/TestCase]] |
skip_testing |
String |
SCAN_SKIP_TESTING |
- |
No | Array of test identifiers to skip. Expected format: TestTarget[/TestSuite[/TestCase]] |
testplan |
String |
SCAN_TESTPLAN |
- |
No | The testplan associated with the scheme that should be used for testing |
only_test_configurations |
String |
SCAN_ONLY_TEST_CONFIGURATIONS |
- |
No | Array of strings matching test plan configurations to run |
skip_test_configurations |
String |
SCAN_SKIP_TEST_CONFIGURATIONS |
- |
No | Array of strings matching test plan configurations to skip |
xctestrun |
String |
SCAN_XCTESTRUN |
- |
No | Run tests using the provided .xctestrun file |
toolchain |
String |
SCAN_TOOLCHAIN |
- |
No | The toolchain that should be used for building the application (e.g. com.apple.dt.toolchain.Swift_2_3, org.swift.30p620160816a) |
clean |
String |
SCAN_CLEAN |
false |
Yes | Should the project be cleaned before building it? |
code_coverage |
Fastlane::Boolean |
SCAN_CODE_COVERAGE |
- |
No | Should code coverage be generated? (Xcode 7 and up) |
address_sanitizer |
Fastlane::Boolean |
- |
- |
No | Should the address sanitizer be turned on? |
thread_sanitizer |
Fastlane::Boolean |
- |
- |
No | Should the thread sanitizer be turned on? |
collect_test_diagnostics |
String |
SCAN_COLLECT_TEST_DIAGNOSTICS |
- |
No | Whether verbose and long-running diagnostics (like sysdiagnoses or log archives) are collected when testing. Valid values are: on-failure or never. If not specified, the value in the test plan is used. Equivalent to -collect-test-diagnostics (Xcode 14 and up) |
open_report |
String |
SCAN_OPEN_REPORT |
false |
Yes | Should the HTML report be opened when tests are completed? |
output_directory |
String |
SCAN_OUTPUT_DIRECTORY |
./test_output |
Yes | The directory in which all reports will be stored |
output_style |
String |
SCAN_OUTPUT_STYLE |
- |
No | Define how the output should look like. Valid values are: standard, basic, rspec, or raw (disables xcpretty during xcodebuild) |
output_types |
String |
SCAN_OUTPUT_TYPES |
html,junit |
Yes | Comma separated list of the output types (e.g. html, junit, json-compilation-database) |
output_files |
String |
SCAN_OUTPUT_FILES |
- |
No | Comma separated list of the output files, corresponding to the types provided by :output_types (order should match). If specifying an output type of json-compilation-database with :use_clang_report_name enabled, that option will take precedence |
buildlog_path |
String |
SCAN_BUILDLOG_PATH |
~/Library/Logs/scan |
Yes | The directory where to store the raw log |
include_simulator_logs |
Fastlane::Boolean |
SCAN_INCLUDE_SIMULATOR_LOGS |
false |
No | If the logs generated by the app (e.g. using NSLog, perror, etc.) in the Simulator should be written to the output_directory |
suppress_xcode_output |
Fastlane::Boolean |
SCAN_SUPPRESS_XCODE_OUTPUT |
- |
No | Suppress the output of xcodebuild to stdout. Output is still saved in buildlog_path |
xcodebuild_formatter |
String |
- |
xcbeautify |
Yes | xcodebuild formatter to use (ex: ‘xcbeautify’, ‘xcbeautify —quieter’, ‘xcpretty’, ‘xcpretty -test’). Use empty string (ex: ”) to disable any formatter (More information: https://docs.fastlane.tools/best-practices/xcodebuild-formatters/) |
output_remove_retry_attempts |
Fastlane::Boolean |
- |
false |
Yes | Remove retry attempts from test results table and the JUnit report (if not using xcpretty) |
force_legacy_xcresulttool |
Fastlane::Boolean |
- |
false |
Yes | Force the use of the ‘—legacy’ flag for xcresulttool instead of using the new commands |
disable_xcpretty |
Fastlane::Boolean |
SCAN_DISABLE_XCPRETTY |
- |
No | DEPRECATED! Use output_style: 'raw' instead - Disable xcpretty formatting of build, similar to output_style='raw' but this will also skip the test results table |
formatter |
String |
SCAN_FORMATTER |
- |
No | DEPRECATED! Use ‘xcpretty_formatter’ instead - A custom xcpretty formatter to use |
xcpretty_formatter |
String |
SCAN_XCPRETTY_FORMATTER |
- |
No | A custom xcpretty formatter to use |
xcpretty_args |
String |
SCAN_XCPRETTY_ARGS |
- |
No | Pass in xcpretty additional command line arguments (e.g. ‘—test —no-color’ or ‘—tap —no-utf’) |
derived_data_path |
String |
SCAN_DERIVED_DATA_PATH |
- |
No | The directory where build products and other derived data will go |
should_zip_build_products |
String |
SCAN_SHOULD_ZIP_BUILD_PRODUCTS |
false |
No | Should zip the derived data build products and place in output path? |
output_xctestrun |
Fastlane::Boolean |
SCAN_OUTPUT_XCTESTRUN |
false |
Yes | Should provide additional copy of .xctestrun file (settings.xctestrun) and place in output path? |
result_bundle_path |
String |
SCAN_RESULT_BUNDLE_PATH |
- |
No | Custom path for the result bundle, overrides result_bundle |
result_bundle |
String |
SCAN_RESULT_BUNDLE |
false |
No | Should an Xcode result bundle be generated in the output directory |
use_clang_report_name |
String |
- |
false |
Yes | Generate the json compilation database with clang naming convention (compile_commands.json) |
parallel_testing |
Fastlane::Boolean |
SCAN_PARALLEL_TESTING |
- |
No | Optionally override the per-target setting in the scheme for running tests in parallel. Equivalent to -parallel-testing-enabled |
concurrent_workers |
Integer |
SCAN_CONCURRENT_WORKERS |
- |
No | Specify the exact number of test runners that will be spawned during parallel testing. Equivalent to -parallel-testing-worker-count |
max_concurrent_simulators |
Integer |
SCAN_MAX_CONCURRENT_SIMULATORS |
- |
No | Constrain the number of simulator devices on which to test concurrently. Equivalent to -maximum-concurrent-test-simulator-destinations |
disable_concurrent_testing |
Fastlane::Boolean |
SCAN_DISABLE_CONCURRENT_TESTING |
false |
No | Do not run test bundles in parallel on the specified destinations. Testing will occur on each destination serially. Equivalent to -disable-concurrent-testing |
skip_build |
Fastlane::Boolean |
SCAN_SKIP_BUILD |
false |
Yes | Should debug build be skipped before test build? |
test_without_building |
Fastlane::Boolean |
SCAN_TEST_WITHOUT_BUILDING |
- |
No | Test without building, requires a derived data path |
build_for_testing |
Fastlane::Boolean |
SCAN_BUILD_FOR_TESTING |
- |
No | Build for testing only, does not run tests |
sdk |
String |
SCAN_SDK |
- |
No | The SDK that should be used for building the application |
configuration |
String |
SCAN_CONFIGURATION |
- |
No | The configuration to use when building the app. Defaults to ‘Release’ |
xcargs |
String |
SCAN_XCARGS |
- |
No | Pass additional arguments to xcodebuild. Be sure to quote the setting names and values e.g. OTHER_LDFLAGS=“-ObjC -lstdc++” |
xcconfig |
String |
SCAN_XCCONFIG |
- |
No | Use an extra XCCONFIG file to build your app |
app_name |
String |
SCAN_APP_NAME |
- |
No | App name to use in slack message and logfile name |
deployment_target_version |
String |
SCAN_DEPLOYMENT_TARGET_VERSION |
- |
No | Target version of the app being build or tested. Used to filter out simulator version |
slack_url |
String |
SLACK_URL |
- |
No | Create an Incoming WebHook for your Slack group to post results there |
slack_channel |
String |
SCAN_SLACK_CHANNEL |
- |
No | #channel or @username |
slack_message |
String |
SCAN_SLACK_MESSAGE |
- |
No | The message included with each message posted to slack |
slack_use_webhook_configured_username_and_icon |
Fastlane::Boolean |
SCAN_SLACK_USE_WEBHOOK_CONFIGURED_USERNAME_AND_ICON |
false |
No | Use webhook’s default username and icon settings? (true/false) |
slack_username |
String |
SCAN_SLACK_USERNAME |
fastlane |
No | Overrides the webhook’s username property if slack_use_webhook_configured_username_and_icon is false |
slack_icon_url |
String |
SCAN_SLACK_ICON_URL |
https://fastlane.tools/assets/img/fastlane_icon.png |
No | Overrides the webhook’s image property if slack_use_webhook_configured_username_and_icon is false |
skip_slack |
String |
SCAN_SKIP_SLACK |
false |
Yes | Don’t publish to slack, even when an URL is given |
slack_only_on_failure |
String |
SCAN_SLACK_ONLY_ON_FAILURE |
false |
Yes | Only post on Slack if the tests fail |
slack_default_payloads |
Array |
SCAN_SLACK_DEFAULT_PAYLOADS |
- |
No | Specifies default payloads to include in Slack messages. For more info visit https://docs.fastlane.tools/actions/slack |
destination |
String |
SCAN_DESTINATION |
- |
No | Use only if you’re a pro, use the other options instead |
run_rosetta_simulator |
Fastlane::Boolean |
SCAN_RUN_ROSETTA_SIMULATOR |
false |
Yes | Adds arch=x86_64 to the xcodebuild ‘destination’ argument to run simulator in a Rosetta mode |
catalyst_platform |
String |
SCAN_CATALYST_PLATFORM |
- |
No | Platform to build when using a Catalyst enabled app. Valid values are: ios, macos |
custom_report_file_name |
String |
SCAN_CUSTOM_REPORT_FILE_NAME |
- |
No | DEPRECATED! Use --output_files instead - Sets custom full report file name when generating a single report |
xcodebuild_command |
String |
GYM_XCODE_BUILD_COMMAND |
env NSUnbufferedIO=YES xcodebuild |
No | Allows for override of the default xcodebuild command |
cloned_source_packages_path |
String |
SCAN_CLONED_SOURCE_PACKAGES_PATH |
- |
No | Sets a custom path for Swift Package Manager dependencies |
package_cache_path |
String |
SCAN_PACKAGE_CACHE_PATH |
- |
No | Sets a custom package cache path for Swift Package Manager dependencies |
skip_package_dependencies_resolution |
Fastlane::Boolean |
SCAN_SKIP_PACKAGE_DEPENDENCIES_RESOLUTION |
false |
Yes | Skips resolution of Swift Package Manager dependencies |
disallow_xcodebuild_settings_lookup |
Fastlane::Boolean |
SCAN_DISALLOW_XCODEBUILD_SETTINGS_LOOKUP |
false |
Yes | Raises an error instead of fetching build settings by running xcodebuild -showBuildSettings, which can take a long time on large projects. The error names the required build setting, so the corresponding option can be specified manually |
disable_package_automatic_updates |
Fastlane::Boolean |
SCAN_DISABLE_PACKAGE_AUTOMATIC_UPDATES |
false |
Yes | Prevents packages from automatically being resolved to versions other than those recorded in the Package.resolved file. This translates in the option -disableAutomaticPackageResolution being passed to xcodebuild |
skip_package_repository_fetches |
Fastlane::Boolean |
SCAN_SKIP_PACKAGE_REPOSITORY_FETCHES |
false |
Yes | Skips updating package dependencies from their remote. This translates in the option -skipPackageUpdates being passed to xcodebuild |
use_system_scm |
Fastlane::Boolean |
SCAN_USE_SYSTEM_SCM |
false |
No | Lets xcodebuild use system’s scm configuration |
number_of_retries |
Integer |
SCAN_NUMBER_OF_RETRIES |
0 |
Yes | The number of times a test can fail |
fail_build |
Fastlane::Boolean |
SCAN_FAIL_BUILD |
true |
Yes | Should this step stop the build if the tests fail? Set this to false if you’re using trainer |
package_authorization_provider |
String |
SCAN_PACKAGE_AUTHORIZATION_PROVIDER |
- |
No | Lets xcodebuild use a specified package authorization provider (keychain|netrc) |
Lane Context Shared Values
This action writes the following values to Actions.lane_context[SharedValues::...]:
| Key | Description |
|---|---|
SharedValues::SCAN_DERIVED_DATA_PATH |
The path to the derived data |
SharedValues::SCAN_GENERATED_PLIST_FILE |
The generated plist file |
SharedValues::SCAN_GENERATED_PLIST_FILES |
The generated plist files |
SharedValues::SCAN_GENERATED_XCRESULT_PATH |
The path to the generated .xcresult |
SharedValues::SCAN_ZIP_BUILD_PRODUCTS_PATH |
The path to the zipped build products |
Examples
run_testsscan # alias for "run_tests"run_tests( workspace: "App.xcworkspace", scheme: "MyTests", clean: false)# Build For Testingrun_tests( derived_data_path: "my_folder", build_for_testing: true)# run tests using derived data from prev. buildrun_tests( derived_data_path: "my_folder", test_without_building: true)# or run it from an existing xctestrun packagerun_tests( xctestrun: "/path/to/mytests.xctestrun")Source & Upstream
- Gem Action:
run_tests.rb - Upstream Source: Inspect Ruby Implementation on GitHub
- Authors:
KrauseFx