public final class

AndroidTestOrchestrator

extends MonitoringInstrumentation
implements TestRunnable.RunFinishedListener
java.lang.Object
   ↳ android.app.Instrumentation
     ↳ android.support.test.internal.runner.hidden.ExposedInstrumentationApi
       ↳ android.support.test.runner.MonitoringInstrumentation
         ↳ android.support.test.orchestrator.AndroidTestOrchestrator

Class Overview

An Instrumentation that executes other instrumentations.

Takes parameters targetPackage and targetInstrumentation, and executes that instrumentation with the same class parameters.

When run normally (i.e. without setting the isolated flag to false) the on device orchestrator will handle test collection and execution. The target instrumentation is executed via shell commmands on the device, with one shell command for test collection, followed by one shell comand per test.

Each test runs in its own isolated process when its own instrumentation.

Setup

The AndroidTestOrchestrator requires installation of a test services APK android.support.test.services, and the stubapp APK android.support.test.orchestrator.stubapp. The orchestrator is technically instrumenting the stubapp, but it's real purpose is to issue commands to ERROR(/AndroidJUnitRunner) or another instrumentation, to run your tests.

Typical usage

Whereas previously you might have called am instrument -w com.example.app/android.support.test.runner.AndroidJUnitRunner you would now execute 'CLASSPATH=$(pm path com.google.android.apps.common.testing.services) app_process / android.support.test.services.shellexecutor.ShellMain am instrument -w -e targetInstrumentation com.example.app/android.support.test.runner.AndroidJUnitRunner android.support.test.orchestrator/android.support.test.orchestrator.AndroidTestOrchestrator'

Pass the -e isolated false flag if you wish the orchestrator to run all your tests in a single process (as if you invoked the target instrumentation directly

All flags besides isolated and targetInstrumentation are passed by the orchestrator to the target instrumentation.

Summary

[Expand]
Inherited Constants
From class android.app.Instrumentation
Public Constructors
AndroidTestOrchestrator()
Public Methods
void finish(int resultCode, Bundle results)
OrchestratorCallback.Stub getCallBack()
Returns a callback representing the OrchestratorCallback.aidl
static AndroidTestOrchestrator getDefaultInstance()
static boolean isSingleMethodTest(String classArg)
void onCreate(Bundle arguments)
boolean onException(Object obj, Throwable e)
void onStart()
void runFinished()
Invoked every time the TestRunnable finishes, including after test collection.
[Expand]
Inherited Methods
From class android.support.test.runner.MonitoringInstrumentation
From class android.support.test.internal.runner.hidden.ExposedInstrumentationApi
From class android.app.Instrumentation
From class java.lang.Object
From interface android.support.test.orchestrator.TestRunnable.RunFinishedListener

Public Constructors

public AndroidTestOrchestrator ()

Public Methods

public void finish (int resultCode, Bundle results)

Parameters
resultCode int
results Bundle

public OrchestratorCallback.Stub getCallBack ()

Returns a callback representing the OrchestratorCallback.aidl

Returns
OrchestratorCallback.Stub An instance of OrchestratorCallback.Stub

public static AndroidTestOrchestrator getDefaultInstance ()

public static boolean isSingleMethodTest (String classArg)

Parameters
classArg String
Returns
boolean

public void onCreate (Bundle arguments)

Parameters
arguments Bundle

public boolean onException (Object obj, Throwable e)

Parameters
obj Object
e Throwable
Returns
boolean

public void onStart ()

public void runFinished ()

Invoked every time the TestRunnable finishes, including after test collection.