Perfecto with Espresso Example

Link to Perfecto with Espresso Example copied to clipboard

Test your Android app for accessibility issues on devices from Perfecto.

Run your UI Tests on Perfecto to get a comprehensive understanding of your app's accessibility health across devices.

Requires:

  • Perfecto Enterprise Private Cloud

Prerequisites

Your UI Tests are integrated with axe DevTools Mobile for Android. Checkout our getting started guide if needed.

Example Project

Looking for an example? Our Sample iOS Project has an integration ready to test.

  1. Finish the prerequisites
  2. Download the sample project from Github
  3. Add your axe DevTools for Mobile API key to app/build.gradle
  4. Adjust the values for cloudURL and securityToken in configFile.json to match your Perfecto cloud:
{
  "cloudURL": "<<perfecto-cloud-name>>",
  "securityToken": "<<security-token>>",
  ...
}
  1. Add your security token as an environment variable (SECURITY_TOKEN) (or attach to end of the next command)
  2. In Terminal, run a test on Perfecto: ./gradlew perfecto-android-inst -PconfigFileLocation=configFile.json -PcloudURL=demo.perfectomobile.com -PsecurityToken=$SECURITY_TOKEN

There are 3 files in the sample project used for Perfecto integration: app/build.gradle, configFile.json, and build.gradle.

Add Perfecto to Your Espresso Test

Setup

  1. In your project's build.gradle, add:

repositories {
  ...
  maven { url "https://repo1.perfectomobile.com/public/repositories/maven" }
  ...
}

dependencies {
  ...
  classpath 'com.perfectomobile.instrumentedtest.gradleplugin:plugin:+'
  ...
}
  1. In app/build.gradle, add:
plugins {
  ...
  id 'com.perfectomobile.instrumentedtest.gradleplugin'
  ...
}
  1. Add Perfectos configuration JSON and review the values cloudURL, securityToken, apkPath and testApkPath to match your Perfecto authentication and application.
{
  "cloudURL": "<<cloud name>>",
  "securityToken": "<<security-token>>",
  "numOfDevices": 2,
  "jobName": "Espresso_Axe_Sample",
  "jobNumber": 1,
  "branch": "some_branch",
  "projectName": "My_Espresso_project",
  "projectVersion": "v1.0",
  "tags": [
    "espresso",
    "plugin"
  ],
  "apkPath": "app/build/outputs/apk/debug/app-debug.apk",
  "testApkPath": "app/build/outputs/apk/androidTest/debug/app-debug-androidTest.apk",
  "installationDetails": {
    "preCleanUp": "true"
  },
  "postExecution": {
    "uninstall": "false"
  },
  "debug": false,
  "failBuildOnFailure": true,
  "takeScreenshotOnTestFailure": true,
  "shard": true,
  "testTimeout": 60000
}

Run

Once your project is setup, run a test on Perfecto from the terminal:

./gradlew perfecto-android-inst -PconfigFileLocation=configFile.json -PcloudURL=demo.perfectomobile.com -PsecurityToken=$SECURITY_TOKEN

cloudURL should reflect your Perfecto cloud URL and securityToken should reflect your Perfecto's security token.