Android Testing with Bitrise

Bitrise is able to run Android Unit tests and UI tests.

The default Android Bitrise configuration runs Android Lint and Unit Tests. To run UI tests we need to add the build step “[BETA] Virtual Device Testing for Android”

  1. Default Bitrise build step “Android Unit Test”

2. Unit tests results are output into “App & Artifacts” tab.

Bitrise tab: Apps and Artifacts (Unit test results)

Extra:

By default, Bitrise zips the test results for unit tests. To generate Unit Tests HTML results report.

  1. We need to write a bash script to move the HTML report to the Bitrise output directory.
  2. Add step “Do anything with Script”, and copy paste below Linux command. Linux command “mv” moves the HTML file to $BITRISE_DEPLOY_DIR location.
#move results to bitrise deploy dir and rename file
$mv /bitrise/src/AppName/./build/reports/tests/testGoogleFlavorAppNameFreeFatReleaseUnitTest/index.html $BITRISE_DEPLOY_DIR/Unit-tests-results.html

3. Now Unit tests HTML report is moved to Bitrise tab “Apps and Artifacts”.

UI test (Espresso tests) are run in Firebase Test Lab (FTL), if you are familiar with FTL is a similar configuration. We need to generate Debug and Test APKs to run UI test on FTL framework.

  1. Open Bitrise workflow.

2. Build Android debug build APK and Android Test APK. To generate Test APK we need to add the build step “Gradle Runner”.

Bitrise step “Android Build” generates Android Debug APK
Bitrise step “Gradle Runner” generates Android Test APK

3. Add build step “[BETA] Virtual Device Testing for Android”

Firebase Test Lab configuration

4. Select Instrumentation Test tab, and configure FTL

Firebase Test Lab configuration

5. Run. We get UI tests results in the “Test reports ->See more tab”

Android UI test(FTL Espresso) results

Is configured by default.

Bitrise generates HTML results report:

Bitrise tab: Apps and Artifacts (Lint test results)

Thanks for reading! Let me know if you have any questions.

Andres

software engineer, read, swim, travel. apps: https://goo.gl/rDuuQw https://goo.gl/15GvfE

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store