Currently supported use cases for the iOS platform

We have prepared some pipeline recipes based on common iOS use cases. These contain some of the most frequent tasks our users need to run.

(iOS) Run tests in parallel on multiple simulators

Description

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.

run_tests_on_simulators Pipeline runs two Stages sequentially:

  1. build_tests stage that runs the build_tests Workflow. This Workflow git clones the sample project and runs the xcode-build-for-test Step to build the target and associated tests. The built test bundle is transferred to the next Stage (run_tests_on_simulators) via the deploy-to-bitrise-io Step.

    The build test bundle is compressed

    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 the deploy-to-bitrise-io Step.

  2. run_tests_on_simulators Stage runs three Workflows in parallel: run_tests_iPad, run_tests_iPhone, and run_tests_iPod. Both of these Workflows use the new xcode-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.

    iOS_example_modified.png

Instructions

To test the configuration in a new Bitrise example project, do the following:

  1. Visit the Create New App page to create a new App.

  2. 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.

  3. Confirm that this is a public repository in the resulting pop-up.

  4. Select the master branch to scan.

  5. Wait for the project scanner to complete.

  6. Select any of the offered Distribution methods (for example development, it does not really matter as now we are focusing on testing).

  7. Confirm the offered stack, skip choosing the app icon and the webhook registration and kick off the first build.

  8. Open the new Bitrise project’s Workflow Editor.

  9. Go to the bitrise.yml tab and replace the existing bitrise.yml with the contents of the example bitrise.yml file.

  10. Click the Start/Schedule a Build button, and select the run_tests_on_simulators option in the “Workflow, Pipeline” dropdown menu at the bottom of the popup.

bitrise.yml

GitHub link: https://github.com/bitrise-io/workflow-recipes/blob/main/recipes/ios-run-tests-in-parallel-on-multiple-simulators.md#bitriseyml

(iOS) Run test groups in parallel

Description

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.

XCode test plans

Xcode Test Plans provide a way to run a collection of tests with different test configurations. raywenderlich.com has a great tutorial on how to get started with Xcode Test Plans.

The example Pipeline config showcases how to run different test groups in parallel.

run_tests_groups Pipeline runs two Stages sequentially:

  1. build_tests Stage that runs the build_tests Workflow. This Workflow git clones the sample project and runs the xcode-build-for-test Step to build the target and associated tests. The built test bundle is transferred to the next Stage (run_tests_groups) via the deploy-to-bitrise-io Step.

  2. run_tests_groups Stage runs two Workflows in parallel: run_ui_tests and run_unit_tests. Both of these Workflows use the new xcode-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.

    iOS_example_2.png

Instructions

  1. Visit the Create New App page to create a new App.

  2. 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.

  3. Confirm that this is a public repository in the resulting pop-up.

  4. Select the master branch to scan.

  5. Wait for the project scanner to complete.

  6. Select any of the offered Distribution methods (for example development, it does not really matter as now we are focusing on testing).

  7. Confirm the offered stack, skip choosing the app icon and the webhook registration and kick off the first build.

  8. Open the new Bitrise project’s Workflow Editor.

  9. Go to the bitrise.yml tab and replace the existing bitrise.yml with the contents of the example bitrise.yml file.

  10. Click the Start/Schedule a Build button, and select the run_tests_groups option in the “Workflow, Pipeline” dropdown menu at the bottom of the popup.

bitrise.yml

GitHub link: https://github.com/bitrise-io/workflow-recipes/blob/main/recipes/ios-run-test-groups-in-parallel.md#bitriseyml

(iOS) Merging test results and deploying to the Test Reports add-on

Description

Test Reports add-on is tied to Bitrise builds. To make all the test reports generated in different builds appear on a single page in the add-on, the reports must be merged and deployed in an additional build.

This example uses the sample-swift-project-with-parallel-ui-test iOS Open Source sample app and extends the ‘Run iOS test groups in parallel’ example Pipeline config with merging and deploying test results.

run_ui_tests and run_unit_tests Workflows are extended with a deploy-to-bitrise-io Step to make the generated test results available for the next Stage.

run_tests_groups Pipeline is extended with a new Stage: deploy_test_results. This Stage runs the deploy_test_results Workflow:

  1. artifact-pull Step downloads all the zipped test results previously generated by Stage: run_tests_groups.

  2. script Step unzips each test result into a new test run directory within the Test Report add-on deploy dir and creates the related test-info.json file.

  3. deploy-to-bitrise-io Step deploys the merged test results.

    iOS_example_3.png

Instructions

  1. Visit the Create New App page to create a new App.

  2. 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.

  3. Confirm that this is a public repository in the resulting pop-up.

  4. Select the master branch to scan.

  5. Wait for the project scanner to complete.

  6. Select any of the offered Distribution methods (for example development, it does not really matter as now we are focusing on testing).

  7. Confirm the offered stack, skip choosing the app icon and the webhook registration and kick off the first build.

  8. Open the new Bitrise project’s Workflow Editor.

  9. Go to the bitrise.yml tab and replace the existing bitrise.yml with the contents of the extended example bitrise.yml file.

  10. Click the Start/Schedule a Build button, and select the run_tests_groups option in the “Workflow, Pipeline” dropdown menu at the bottom of the popup.

  11. Open the Pipeline’s build page.

  12. Select the deploy_test_results build.

  13. Click on Details & Add-ons on the build details page and select the Test Reports add-on to view the merged test reports.

bitrise.yml

GitHub link: https://github.com/bitrise-io/workflow-recipes/blob/main/recipes/ios-merging-test-results-and-deploying-to-the-test-reports-add-on.md#bitriseyml