Testlab

Android

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!

(courseCode)-(android)-hw[0..9]

Examples:

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

Configure your repository

1. Enable Shared Runner

Navigate 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 as a member with Maintainer permission, and then click "Invite."

Alt

3. Commit your application source code

NB! Ensure you have 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:

This type of testing requires you to write Espresso tests. Copy this file to your .gitlab-ci.yml script to start using this service.

.gitlab-ci.yml
# Base Docker Image
image: inovex/gitlab-ci-android
# Environment Variables
variables:
GRADLE_OPTS: "-Dorg.gradle.daemon=false" # Disable Gradle Daemon
# Cache Configuration for Faster Builds
cache:
key: ${CI_PROJECT_ID}
paths:
- .gradle/
# Build Stage
assembleArtifacts:
stage: build
allow_failure: false
when: manual
before_script:
- export GRADLE_USER_HOME=$(pwd)/.gradle # Set up Gradle cache
- chmod +x ./gradlew # Make Gradle executable
script:
- ./gradlew assembleDebug
- mkdir -p artifacts
- mv $(find . -type f -name "*debug.apk") artifacts/app-debug.apk
artifacts:
paths:
- artifacts
# Test Stage
testArtifacts:
stage: test
dependencies:
- assembleArtifacts
script:
# Trigger Jenkins build for testing
- >
curl -X POST https://jenkins.testlab.ttu.ee/buildByToken/buildWithParameters?job=Android
-F token=gW0QBcGUftU5RJNVPlr3Fkrh8D7WSk5s
-F projectId=${CI_PROJECT_ID}
-F jobId=${CI_JOB_ID}
-F testingType=screenshot
-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
# Base Docker Image
image: inovex/gitlab-ci-android
# Environment Variables
variables:
GRADLE_OPTS: "-Dorg.gradle.daemon=false" # Disable Gradle Daemon
# Cache Configuration for Faster Builds
cache:
key: ${CI_PROJECT_ID}
paths:
- .gradle/
# Build Stage
assembleArtifacts:
stage: build
allow_failure: false
when: manual
before_script:
- export GRADLE_USER_HOME=$(pwd)/.gradle # Set up Gradle cache
- chmod +x ./gradlew # Make Gradle executable
script:
- ./gradlew assembleDebug # Compile Debug APK
- ./gradlew assembleAndroidTest # Compile Test APK
- mkdir -p artifacts # Create artifacts directory
- mv $(find . -type f -name "*debug.apk") artifacts/app-debug.apk # Move Debug APK
- mv $(find . -type f -name "*androidTest.apk") artifacts/app-debug-androidTest.apk # Move Test APK
artifacts:
paths:
- artifacts
# Test Stage
testArtifacts:
stage: test
dependencies:
- assembleArtifacts
script:
# Trigger Jenkins build for testing
- >
curl -X POST https://jenkins.testlab.ttu.ee/buildByToken/buildWithParameters?job=Android
-F token=gW0QBcGUftU5RJNVPlr3Fkrh8D7WSk5s
-F projectId=${CI_PROJECT_ID}
-F jobId=${CI_JOB_ID}
-F testingType=espresso
-F email=${GITLAB_USER_EMAIL}
-F repositoryName=${CI_PROJECT_NAME}

🔗 Check out these links 🔗

Espresso testing (UI)

Example Android App Code

Virtual Testing Lab (OpenSTF)

Intended for testing your application on physical devices remotely, these devices are housed in our lab. You can use your web browser to install, test applications, and more.

NB! Ensure you review the rules before using.

Click on any device you wish to test on. It might take a while to load the device. If you encounter a message stating that the device has been "stolen," simply click on "Try to reconnect."

  • Turning off devices is prohibited.
  • Disabling developer mode or USB is prohibited.
  • Avoid installing or downloading software you're unfamiliar with.
  • Refrain from unethical actions.
  • If you encounter issues or malfunctions, please notify Kevin Janson. We maintain logs detailing user activities.

Happy testing!

Click here to access the virtual lab