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:
-
build_for_ui_testing
: This Stage executes a Workflow — also namedbuild_for_ui_testing
— that runs theandroid-build-for-ui-testing
Step to build APKs for use in testing, and runs thedeploy-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. -
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 theandroid-instrumented-test
Step to run the UI tests on the APKs built in the previous Workflow on each specific device type.
Instructions
To test this configuration in a new Bitrise example project, do the following:
-
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/Bitrise-Android-Modules-Sample.git
) in the Git repository (clone) URL field. -
Confirm that this is a public repository in the resulting pop-up.
-
Select the
main
branch to scan. -
Wait for the project scanner to complete.
-
Enter
app
as the specified module. -
Enter
debug
as the specified variant. -
Continue through the prompts as normal — no changes are needed.
-
Open the new Bitrise project’s Workflow Editor.
-
Go to the bitrise.yml tab, and replace the existing yaml contents with the contents of the example
bitrise.yml
. -
Click the
button, and select theui_test_on_multiple_devices
option in the dropdown menu at the bottom of the popup.
bitrise.yml
(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:
-
unit_tests
: This Workflow simply runs the unit tests of the given module and variant using theandroid-unit-test
Step. -
ui_tests
: This Workflow builds the given module and variant using theandroid-build-for-ui-testing
Step, spins up an emulator using theavd-manager
Step, waits for the emulator to boot using thewait-for-android-emulator
Step, and runs the UI tests using theandroid-instrumented-test
Step.
Instructions
-
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/Bitrise-Android-Modules-Sample.git
) in the Git repository (clone) URL field. -
Confirm that this is a public repository in the resulting pop-up.
-
Select the
main
branch to scan. -
Wait for the project scanner to complete.
-
Enter
app
as the specified module. -
Enter
debug
as the specified variant. -
Continue through the prompts as normal — no changes are needed.
-
Open the new Bitrise project’s Workflow Editor.
-
Go to the bitrise.yml tab, and replace the existing yaml contents with the contents of the example
bitrise.yml
. -
Click the
button, and select thepipeline_unit_and_ui_test
option in the 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:
-
unit_test_app
: This Workflow runs the unit tests of the app module using theandroid-unit-test
Step. -
unit_test_library
: This Workflow runs the unit tests of thelib-example
module using theandroid-unit-test
Step.
Instructions
-
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/Bitrise-Android-Modules-Sample.git
) in the Git repository (clone) URL field. -
Confirm that this is a public repository in the resulting pop-up.
-
Select the
main
branch to scan. -
Wait for the project scanner to complete.
-
Enter
app
as the specified module. -
Enter
debug
as the specified variant. -
Continue through the prompts as normal — no changes are needed.
-
Open the new Bitrise project’s Workflow Editor.
-
Go to the bitrise.yml tab, and replace the existing yaml contents with the contents of the example
bitrise.yml
. -
Click the
button, and select thepipeline_unit_test
option in the dropdown menu at the bottom of the popup.