Real Device Continuous Integration

Appium uses a service called TestObject that allows us to run automated functional tests against real devices.

How it works

Environment

Example

// This script, if run before the rest of the tests, will use TestObject appium staging server
import { enableTestObject, disableTestObject } from 'appium-test-support';
import wd from 'wd';
import { startServer, DEFAULT_PORT } from '../../..';
import logger from '../../../lib/logger';

if (process.env.TESTOBJECT_E2E_TESTS) {
  logger.debug('Running tests on TestObject');

  let wdObject;
  before(async function () {
    // Use a commit SHA as the git branch
    const branch = process.env.COMMIT_HASH || process.env.TRAVIS_COMMIT;
    if (!branch) {
      throw new Error(`A commit must be provided in $COMMIT_HASH`);
    }
    // Uploads the zip and injects 'appium-uiautomator2-driver' as the branch
    wdObject = await enableTestObject(wd, 'appium-uiautomator2-driver', `git@github.com:appium/appium-uiautomator2-driver.git#${branch}`);
  });
  after(async function () {
    // Reverses the overriding of 'wd'
    await disableTestObject(wdObject);
  });

} else {
  before(async function () {
    // If we're not using TestObject, we're using a local server
    await startServer(DEFAULT_PORT, 'localhost');
  });
}