This example uses the sample-swift-project-with-parallel-ui-test iOS Open Source sample app, which has some example Unit and UI tests and uses Test Plans to group the tests.
The example Pipeline config showcases how to run all the test cases of the project on different iOS simulators.
build_and_run_tests
pipeline's Workflows can be split into two logical groups:
-
Build tests: The
xcode_build_for_test
Workflow git clones the sample project and runs thexcode-build-for-test
Step to build the target and associated tests. The built test bundle is shared with the other workflows via thedeploy-to-bitrise-io
Step.Note:
xcode-build-for-test
Step compresses the built test bundle and moves the generated zip to the$BITRISE_DEPLOY_DIR
, that directory’s content is deployed to the Workflow artifacts by default via thedeploy-to-bitrise-io
Step. -
Run tests: Three Workflows are exsted in parallel:
run_tests_on_iPhone
,run_tests_on_iPad
, andrun_tests_on_iPod
. All of these Workflows use the newxcode-test-without-building
Step, which executes the tests based on the previous Stage built test bundle. The pre-built test bundle is pulled by the_pull_test_bundle
utility Workflow.
- Visit the Create New App page to create a new App.
- When prompted to select a git repository, choose Other/Manual and paste the sample project repository URL (
https://github.com/bitrise-io/sample-swift-project-with-parallel-ui-test
) in the Git repository (clone) URL field. - Confirm that this is a public repository in the resulting pop-up.
- Select the
master
branch to scan. - Wait for the project scanner to complete.
- Select any of the offered Distribution methods (for example development, it does not really matter as now we are focusing on testing).
- Confirm the offered stack, skip choosing the app icon and the webhook registration and kick off the first build.
- Open the new Bitrise project’s Workflow Editor.
- Go to the bitrise.yml tab and replace the existing
bitrise.yml
with the contents of the example bitrise.yml below. - Click the Start/Schedule a Build button, and select the
build_and_run_tests
option in the Workflow, Pipeline dropdown menu at the bottom of the popup.
---
format_version: '17'
default_step_lib_source: https://github.com/bitrise-io/bitrise-steplib.git
project_type: ios
app:
envs:
- BITRISE_PROJECT_PATH: BullsEye.xcworkspace
- BITRISE_SCHEME: BullsEye
meta:
bitrise.io:
stack: osx-xcode-16.0.x
machine_type_id: g2.mac.medium
pipelines:
build_and_run_tests:
workflows:
xcode_build_for_test: {}
run_tests_on_iPhone:
depends_on: [xcode_build_for_test]
run_tests_on_iPad:
depends_on: [xcode_build_for_test]
run_tests_on_iPod:
depends_on: [xcode_build_for_test]
workflows:
xcode_build_for_test:
steps:
- git-clone@8: {}
- xcode-build-for-test@3:
inputs:
- destination: generic/platform=iOS Simulator
- deploy-to-bitrise-io@2:
inputs:
- pipeline_intermediate_files: "$BITRISE_TEST_BUNDLE_PATH:BITRISE_TEST_BUNDLE_PATH"
run_tests_on_iPhone:
before_run:
- _pull_test_bundle
steps:
- xcode-test-without-building@0:
inputs:
- xctestrun: "$BITRISE_TEST_BUNDLE_PATH/BullsEye_FullTests_iphonesimulator15.2-arm64-x86_64.xctestrun"
- destination: platform=iOS Simulator,name=iPhone 12 Pro Max
run_tests_on_iPad:
before_run:
- _pull_test_bundle
steps:
- xcode-test-without-building@0:
inputs:
- xctestrun: "$BITRISE_TEST_BUNDLE_PATH/BullsEye_FullTests_iphonesimulator15.2-arm64-x86_64.xctestrun"
- destination: platform=iOS Simulator,name=iPad (9th generation)
run_tests_on_iPod:
before_run:
- _pull_test_bundle
steps:
- xcode-test-without-building@0:
inputs:
- xctestrun: "$BITRISE_TEST_BUNDLE_PATH/BullsEye_FullTests_iphonesimulator15.2-arm64-x86_64.xctestrun"
- destination: platform=iOS Simulator,name=iPod touch (7th generation)
_pull_test_bundle:
steps:
- pull-intermediate-files@1:
inputs:
- artifact_sources: xcode_build_for_test