Skip to content

Android

There are three available modes for Android testing.
To start testing, you must first configure your repository.

Please adhere to the repository naming convention:

⚠️ One application per repository!

Follow this naming convention: (courseCode)-android-hw[0..9]

Examples:

  • ICD0022-android-hw0
  • ICD0022-android-hw7

Configure your repository

1. Enable Shared Runner

Go to Settings → CI/CD → Runners → Expand → Enable Shared Runners Alt

2. Add user @testlab with Maintainer permission to the repository

Navigate to Members, add @testlab with Maintainer permission, then click Invite.

Alt

3. Commit your application source code

⚠️ Ensure there is only one app per repository.

Your repository structure should resemble the following. Then click "Setup CI/CD"

Alt

4. Based on your requirements, replace the script of your .gitlab-ci.yml file

Click "Configure pipeline."

Alt

Depending on the test you'd like to run, click the link below and copy the .gitlab-ci.yml script to your .gitlab-ci.yml, then commit it.

Screenshot test - Use this to verify that your app compiles and runs on devices. It's ideal for testing Single Page Applications.

Espresso test - Use this to run your written Espresso tests on devices.

5. Next, navigate to CI/CD and initiate your job

Go to Build-> Jobs and click ▶️

After clicking ▶️, the pipeline will start. You must manually start the pipeline each time you commit and push your code to GitLab. The pipeline usually takes between 5 to 30 minutes to run. You'll receive your test results at your UNIID email.

Alt

6. Congratulations, you did it! 🤩🤩

If you don't receive your results within 30 minutes, contact me on Teams (Kevin Janson) or at testlab@ttu.ee.

Happy testing!

Screenshot Testing

This testing method doesn't require you to write any tests. The script will automatically compile your code and then install it on all available devices on Testlab. It'll capture both portrait and landscape screenshots. It's suitable for testing Single Page Applications or simply verifying that your app installs on the devices.

Copy the following file to your .gitlab-ci.yml script to use this service:

.gitlab-ci.yml
## Android Screenshot test
image: inovex/gitlab-ci-android

variables:
  GRADLE_OPTS: "-Dorg.gradle.daemon=true -Dorg.gradle.caching=true"

cache:
  key: "${CI_PROJECT_ID}"
  paths:
    - .gradle/

androidScreenshotTest:
  when: manual
  script:
    - export GRADLE_USER_HOME="$(pwd)/.gradle"
    - ./gradlew assembleDebug --build-cache --configure-on-demand --parallel
    - mkdir -p artifacts
    - mv app/build/outputs/apk/debug/app-debug.apk artifacts/app-debug.apk
    - |
      curl -X POST --location "https://testlab.taltech.ee/testlab/startTest" \
        -F "platform=android" \
        -F "reportType=screenshot" \
        -F "apkFile=@artifacts/app-debug.apk" \
        -F "email=${GITLAB_USER_EMAIL}" \
        -F "repositoryName=${CI_PROJECT_NAME}"

Espresso Testing

This testing method requires you to write Espresso tests. To start using this service, copy the following file to your .gitlab-ci.yml script:

.gitlab-ci.yml
#Android Espresso test
image: inovex/gitlab-ci-android

variables:
  GRADLE_OPTS: "-Dorg.gradle.daemon=true -Dorg.gradle.caching=true"

cache:
  key: "${CI_PROJECT_ID}"
  paths:
    - .gradle/

androidEspressoTest:
  when: manual
  script:
    - export GRADLE_USER_HOME="$(pwd)/.gradle"
    - ./gradlew assembleDebug assembleAndroidTest --build-cache --configure-on-demand --parallel
    - mkdir -p artifacts
    - mv app/build/outputs/apk/debug/app-debug.apk artifacts/app-debug.apk
    - mv app/build/outputs/apk/androidTest/debug/app-debug-androidTest.apk artifacts/app-debug-androidTest.apk
    - |
      curl -X POST --location "https://testlab.taltech.ee/testlab/startTest" \
        -F "platform=android" \
        -F "reportType=espresso" \
        -F "apkFile=@artifacts/app-debug.apk" \
        -F "debugFile=@artifacts/app-debug-androidTest.apk" \
        -F "email=${GITLAB_USER_EMAIL}" \
        -F "repositoryName=${CI_PROJECT_NAME}"

🔗 Check out these links 🔗

Espresso testing (UI)

Example Android App Code

Feedback