Skip to content

Latest commit

 

History

History
69 lines (54 loc) · 2.23 KB

android-parallel-testing-unit-test-shards.md

File metadata and controls

69 lines (54 loc) · 2.23 KB

(Android) Unit test sharding by module

Description

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

This Pipeline contains two Workflows which are executed 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.

A screenshot of the example Pipeline in Bitrise's web UI

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

format_version: "17"
default_step_lib_source: https://github.com/bitrise-io/bitrise-steplib.git
project_type: android

meta:
  bitrise.io:
    stack: linux-docker-android-22.04
    machine_type_id: standard

pipelines:
  pipeline_unit_test:
    workflows:
      unit_test_app: {}
      unit_test_library: {}

workflows:
  unit_test_app:
    envs:
    - MODULE: app
    - VARIANT: debug
    after_run:
    - _test

  unit_test_library:
    envs:
    - MODULE: lib-example
    after_run:
    - _test

  _test:
    steps:
    - git-clone@8: {}
    - android-unit-test@1:
        inputs:
        - module: $MODULE
        - variant: $VARIANT