Currently supported use cases for the Android platform

We have prepared some pipeline recipes based on common Android use cases. These contain some of the most frequent tasks our users need to run. The examples include entire Workflows that can be copied and pasted for the most part.

(Android) Run UI tests in parallel on multiple devices or shards

Description

Running the UI (instrumentation) tests of a single module in parallel Workflows utilizing pipelines. You can run the tests in parallel by shards or by devices.

The Pipeline contains two Stages that are run serially:

  1. build_for_ui_testing: This Stage executes a Workflow — also named build_for_ui_testing — that runs the android-build-for-ui-testing Step to build APKs for use in testing, and runs the deploy-to-bitrise-io Step to save those APKs for use in the later Stages. Performing this Stage separately from the actual testing allows for each test Stage to use these pre-built APKs rather than having to rebuild them for each test Stage.

  2. run_ui_tests_on_devices: This Stage executes three UI test Workflows in parallel — ui_test_on_phone, ui_test_on_tablet, ui_test_on_foldable — which use the android-instrumented-test Step to run the UI tests on the APKs built in the previous Workflow on each specific device type.

    android_example.png

Instructions

To test this 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/Bitrise-Android-Modules-Sample.git) in the Git repository (clone) URL field.

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

  4. Select the main branch to scan.

  5. Wait for the project scanner to complete.

  6. Enter app as the specified module.

  7. Enter debug as the specified variant.

  8. Continue through the prompts as normal — no changes are needed.

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

  10. Go to the bitrise.yml tab, and replace the existing yaml contents with the contents of the example bitrise.yml.

  11. Click the Start/Schedule a Build button, and select the ui_test_on_multiple_devices 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/android-parallel-ui-tests-on-multiple-devices.md#bitriseyml

(Android) Running unit and UI tests in parallel

Description

Run unit tests and UI tests in parallel utilizing Pipelines.

This Pipeline contains one Stage — stage_unit_and_ui_test — that executes two Workflows in parallel:

  1. unit_tests: This Workflow simply runs the unit tests of the given module and variant using the android-unit-test Step.

  2. ui_tests: This Workflow builds the given module and variant using the android-build-for-ui-testing Step, spins up an emulator using the avd-manager Step, waits for the emulator to boot using the wait-for-android-emulator Step, and runs the UI tests using the android-instrumented-test Step.

    android_example2.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/Bitrise-Android-Modules-Sample.git) in the Git repository (clone) URL field.

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

  4. Select the main branch to scan.

  5. Wait for the project scanner to complete.

  6. Enter app as the specified module.

  7. Enter debug as the specified variant.

  8. Continue through the prompts as normal — no changes are needed.

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

  10. Go to the bitrise.yml tab, and replace the existing yaml contents with the contents of the example bitrise.yml.

  11. Click the Start/Schedule a Build button, and select the pipeline_unit_and_ui_test 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/android-parallel-unit-and-ui-tests.md#bitriseyml

(Android) Unit test sharding by module

Description

Run the unit tests of a modularized app in parallel Workflows utilizing Pipelines.

This Pipeline contains one Stage — stage_unit_test — that executes two Workflows in parallel:

  1. unit_test_app: This Workflow runs the unit tests of the app module using the android-unit-test Step.

  2. unit_test_library: This Workflow runs the unit tests of the lib-example module using the android-unit-test Step.

    android_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/Bitrise-Android-Modules-Sample.git) in the Git repository (clone) URL field.

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

  4. Select the main branch to scan.

  5. Wait for the project scanner to complete.

  6. Enter app as the specified module.

  7. Enter debug as the specified variant.

  8. Continue through the prompts as normal — no changes are needed.

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

  10. Go to the bitrise.yml tab, and replace the existing yaml contents with the contents of the example bitrise.yml.

  11. Click the Start/Schedule a Build button, and select the pipeline_unit_test 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/android-parallel-testing-unit-test-shards.md#bitriseyml