Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)   
Deprecated in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Constants](https://developer.android.com/reference/android/test/InstrumentationTestRunner#constants) \| [Inherited Constants](https://developer.android.com/reference/android/test/InstrumentationTestRunner#inhconstants) \| [Ctors](https://developer.android.com/reference/android/test/InstrumentationTestRunner#pubctors) \| [Methods](https://developer.android.com/reference/android/test/InstrumentationTestRunner#pubmethods) \| [Protected Methods](https://developer.android.com/reference/android/test/InstrumentationTestRunner#promethods) \| [Inherited Methods](https://developer.android.com/reference/android/test/InstrumentationTestRunner#inhmethods)

# InstrumentationTestRunner

*** ** * ** ***

` public class InstrumentationTestRunner `   
` ` ` extends https://developer.android.com/reference/android/app/Instrumentation ` ` implements https://developer.android.com/reference/android/test/TestSuiteProvider `

|---|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) |||
| ↳ | [android.app.Instrumentation](https://developer.android.com/reference/android/app/Instrumentation) ||
|   | ↳ | android.test.InstrumentationTestRunner |

<br />

*** ** * ** ***

<br />

**This class was deprecated in API level 24.**   

Use [AndroidJUnitRunner](https://developer.android.com/reference/android/support/test/runner/AndroidJUnitRunner) instead. New tests should be written using the [Android Testing Support Library](https://developer.android.com/tools/testing-support-library).

An `https://developer.android.com/reference/android/app/Instrumentation` that runs various types of `https://developer.android.com/reference/junit/framework/TestCase`s against an Android package (application).

### Developer Guides

For more information about application testing, read the [Testing](https://developer.android.com/guide/topics/testing) developer guide.

### Typical Usage

1. Write `https://developer.android.com/reference/junit/framework/TestCase`s that perform unit, functional, or performance tests against the classes in your package. Typically these are subclassed from:
   - `https://developer.android.com/reference/android/test/ActivityInstrumentationTestCase2`
   - `https://developer.android.com/reference/android/test/ActivityUnitTestCase`
   - `https://developer.android.com/reference/android/test/AndroidTestCase`
   - `https://developer.android.com/reference/android/test/ApplicationTestCase`
   - `https://developer.android.com/reference/android/test/InstrumentationTestCase`
   - `https://developer.android.com/reference/android/test/ProviderTestCase`
   - `https://developer.android.com/reference/android/test/ServiceTestCase`
   - `https://developer.android.com/reference/android/test/SingleLaunchActivityTestCase`
2. Set the `android:targetPackage` attribute of the `<instrumentation>` element in the test package's manifest. You should set the attribute value to the package name of the target application under test.
3. Run the instrumentation using "adb shell am instrument -w", with no optional arguments, to run all tests (except performance tests).
4. Run the instrumentation using "adb shell am instrument -w", with the argument '-e func true' to run all functional tests. These are tests that derive from `https://developer.android.com/reference/android/test/InstrumentationTestCase`.
5. Run the instrumentation using "adb shell am instrument -w", with the argument '-e unit true' to run all unit tests. These are tests that *do not*derive from `https://developer.android.com/reference/android/test/InstrumentationTestCase` (and are not performance tests).
6. Run the instrumentation using "adb shell am instrument -w", with the argument '-e class' set to run an individual `https://developer.android.com/reference/junit/framework/TestCase`.

<br />

**Running all tests:** adb shell am instrument -w com.android.foo/android.test.InstrumentationTestRunner

<br />

**Running all small tests:** adb shell am instrument -w -e size small com.android.foo/android.test.InstrumentationTestRunner

<br />

**Running all medium tests:** adb shell am instrument -w -e size medium com.android.foo/android.test.InstrumentationTestRunner

<br />

**Running all large tests:** adb shell am instrument -w -e size large com.android.foo/android.test.InstrumentationTestRunner

<br />

**Filter test run to tests with given annotation:** adb shell am instrument -w -e annotation com.android.foo.MyAnnotation com.android.foo/android.test.InstrumentationTestRunner

<br />

If used with other options, the resulting test run will contain the union of the two options. e.g. "-e size large -e annotation com.android.foo.MyAnnotation" will run only tests with both the `https://developer.android.com/reference/android/test/suitebuilder/annotation/LargeTest` and "com.android.foo.MyAnnotation" annotations.

<br />

**Filter test run to tests *without* given annotation:** adb shell am instrument -w -e notAnnotation com.android.foo.MyAnnotation com.android.foo/android.test.InstrumentationTestRunner

<br />

**Running a single testcase:** adb shell am instrument -w -e class com.android.foo.FooTest com.android.foo/android.test.InstrumentationTestRunner

<br />

**Running a single test:** adb shell am instrument -w -e class com.android.foo.FooTest#testFoo com.android.foo/android.test.InstrumentationTestRunner

<br />

**Running multiple tests:** adb shell am instrument -w -e class com.android.foo.FooTest,com.android.foo.TooTest com.android.foo/android.test.InstrumentationTestRunner

<br />

**Running all tests in a java package:** adb shell am instrument -w -e package com.android.foo.subpkg com.android.foo/android.test.InstrumentationTestRunner

<br />

**Including performance tests:** adb shell am instrument -w -e perf true com.android.foo/android.test.InstrumentationTestRunner

<br />

**To debug your tests, set a break point in your code and pass:** -e debug true

<br />

**To run in 'log only' mode** -e log true This option will load and iterate through all test classes and methods, but will bypass actual test execution. Useful for quickly obtaining info on the tests to be executed by an instrumentation command.

<br />

**To generate EMMA code coverage:** -e coverage true Note: this requires an emma instrumented build. By default, the code coverage results file will be saved in a /data/ /coverage.ec file, unless overridden by coverageFile flag (see below)

<br />

**To specify EMMA code coverage results file path:** -e coverageFile /sdcard/myFile.ec   
in addition to the other arguments.

<br />

## Summary

| ### Constants ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/test/InstrumentationTestRunner#REPORT_KEY_NAME_CLASS` If included in the status or final bundle sent to an IInstrumentationWatcher, this key identifies the name of the current test class. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/test/InstrumentationTestRunner#REPORT_KEY_NAME_TEST` If included in the status or final bundle sent to an IInstrumentationWatcher, this key identifies the name of the current test. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/test/InstrumentationTestRunner#REPORT_KEY_NUM_CURRENT` If included in the status or final bundle sent to an IInstrumentationWatcher, this key identifies the sequence number of the current test. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/test/InstrumentationTestRunner#REPORT_KEY_NUM_TOTAL` If included in the status or final bundle sent to an IInstrumentationWatcher, this key identifies the total number of tests that are being run. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/test/InstrumentationTestRunner#REPORT_KEY_STACK` If included in the status bundle sent to an IInstrumentationWatcher, this key identifies a stack trace describing an error or failure. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/test/InstrumentationTestRunner#REPORT_VALUE_ID` This value, if stored with key `https://developer.android.com/reference/android/app/Instrumentation#REPORT_KEY_IDENTIFIER`, identifies InstrumentationTestRunner as the source of the report. |
| `int` | `https://developer.android.com/reference/android/test/InstrumentationTestRunner#REPORT_VALUE_RESULT_ERROR` The test completed with an error. |
| `int` | `https://developer.android.com/reference/android/test/InstrumentationTestRunner#REPORT_VALUE_RESULT_FAILURE` The test completed with a failure. |
| `int` | `https://developer.android.com/reference/android/test/InstrumentationTestRunner#REPORT_VALUE_RESULT_OK` The test completed successfully. |
| `int` | `https://developer.android.com/reference/android/test/InstrumentationTestRunner#REPORT_VALUE_RESULT_START` The test is starting. |

### Inherited constants

From class `https://developer.android.com/reference/android/app/Instrumentation` `https://developer.android.com/reference/java/lang/String` `https://developer.android.com/reference/android/app/Instrumentation#REPORT_KEY_IDENTIFIER`

If included in the status or final bundle sent to an IInstrumentationWatcher, this key identifies the class that is writing the report.
`https://developer.android.com/reference/java/lang/String` `https://developer.android.com/reference/android/app/Instrumentation#REPORT_KEY_STREAMRESULT`

If included in the status or final bundle sent to an IInstrumentationWatcher, this key identifies a string which can simply be printed to the output stream.

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/android/test/InstrumentationTestRunner#InstrumentationTestRunner()() ` |

| ### Public methods ||
|---|---|
| ` TestSuite` | ` https://developer.android.com/reference/android/test/InstrumentationTestRunner#getAllTests()() ` Override this to define all of the tests to run in your package. |
| ` https://developer.android.com/reference/android/os/Bundle` | ` https://developer.android.com/reference/android/test/InstrumentationTestRunner#getArguments()() ` Get the arguments passed to this instrumentation. |
| ` https://developer.android.com/reference/java/lang/ClassLoader` | ` https://developer.android.com/reference/android/test/InstrumentationTestRunner#getLoader()() ` Override this to provide access to the class loader of your package. |
| ` TestSuite` | ` https://developer.android.com/reference/android/test/InstrumentationTestRunner#getTestSuite()() ` <br /> |
| ` void` | ` https://developer.android.com/reference/android/test/InstrumentationTestRunner#onCreate(android.os.Bundle)(https://developer.android.com/reference/android/os/Bundle arguments) ` Called when the instrumentation is starting, before any application code has been loaded. |
| ` void` | ` https://developer.android.com/reference/android/test/InstrumentationTestRunner#onStart()() ` Method where the instrumentation thread enters execution. |

| ### Protected methods ||
|---|---|
| ` void` | ` https://developer.android.com/reference/android/test/InstrumentationTestRunner#addTestListener(TestListener)(TestListener listener) ` Add a `https://developer.android.com/` |
| ` https://developer.android.com/reference/android/test/AndroidTestRunner` | ` https://developer.android.com/reference/android/test/InstrumentationTestRunner#getAndroidTestRunner()() ` |

### Inherited methods

From class ` https://developer.android.com/reference/android/app/Instrumentation ` ` https://developer.android.com/reference/android/os/TestLooperManager` ` https://developer.android.com/reference/android/app/Instrumentation#acquireLooperManager(android.os.Looper)(https://developer.android.com/reference/android/os/Looper looper) `

Takes control of the execution of messages on the specified looper until `https://developer.android.com/reference/android/os/TestLooperManager#release()` is called.
` https://developer.android.com/reference/android/app/Instrumentation.ActivityMonitor` ` https://developer.android.com/reference/android/app/Instrumentation#addMonitor(java.lang.String,%20android.app.Instrumentation.ActivityResult,%20boolean)(https://developer.android.com/reference/java/lang/String cls, https://developer.android.com/reference/android/app/Instrumentation.ActivityResult result, boolean block) `

A convenience wrapper for `https://developer.android.com/reference/android/app/Instrumentation#addMonitor(android.app.Instrumentation.ActivityMonitor)` that creates a class matching `https://developer.android.com/reference/android/app/Instrumentation.ActivityMonitor` for you and returns it.
` https://developer.android.com/reference/android/app/Instrumentation.ActivityMonitor` ` https://developer.android.com/reference/android/app/Instrumentation#addMonitor(android.content.IntentFilter,%20android.app.Instrumentation.ActivityResult,%20boolean)(https://developer.android.com/reference/android/content/IntentFilter filter, https://developer.android.com/reference/android/app/Instrumentation.ActivityResult result, boolean block) `

A convenience wrapper for `https://developer.android.com/reference/android/app/Instrumentation#addMonitor(android.app.Instrumentation.ActivityMonitor)` that creates an intent filter matching `https://developer.android.com/reference/android/app/Instrumentation.ActivityMonitor` for you and returns it.
` void` ` https://developer.android.com/reference/android/app/Instrumentation#addMonitor(android.app.Instrumentation.ActivityMonitor)(https://developer.android.com/reference/android/app/Instrumentation.ActivityMonitor monitor) `

Add a new `https://developer.android.com/reference/android/app/Instrumentation.ActivityMonitor` that will be checked whenever an activity is started.
` void` ` https://developer.android.com/reference/android/app/Instrumentation#addResults(android.os.Bundle)(https://developer.android.com/reference/android/os/Bundle results) `

Report some results in the middle of instrumentation execution.
` void` ` https://developer.android.com/reference/android/app/Instrumentation#callActivityOnCreate(android.app.Activity,%20android.os.Bundle)(https://developer.android.com/reference/android/app/Activity activity, https://developer.android.com/reference/android/os/Bundle icicle) `

Perform calling of an activity's `https://developer.android.com/reference/android/app/Activity#onCreate(android.os.Bundle)` method.
` void` ` https://developer.android.com/reference/android/app/Instrumentation#callActivityOnCreate(android.app.Activity,%20android.os.Bundle,%20android.os.PersistableBundle)(https://developer.android.com/reference/android/app/Activity activity, https://developer.android.com/reference/android/os/Bundle icicle, https://developer.android.com/reference/android/os/PersistableBundle persistentState) `

Perform calling of an activity's `https://developer.android.com/reference/android/app/Activity#onCreate(android.os.Bundle)` method.
` void` ` https://developer.android.com/reference/android/app/Instrumentation#callActivityOnDestroy(android.app.Activity)(https://developer.android.com/reference/android/app/Activity activity) ` ` void` ` https://developer.android.com/reference/android/app/Instrumentation#callActivityOnNewIntent(android.app.Activity,%20android.content.Intent,%20android.app.ComponentCaller)(https://developer.android.com/reference/android/app/Activity activity, https://developer.android.com/reference/android/content/Intent intent, https://developer.android.com/reference/android/app/ComponentCaller caller) `

Same as `https://developer.android.com/reference/android/app/Instrumentation#callActivityOnNewIntent(android.app.Activity,%20android.content.Intent)`, but with an extra parameter for the `https://developer.android.com/reference/android/app/ComponentCaller` instance associated with the app that sent the intent.
` void` ` https://developer.android.com/reference/android/app/Instrumentation#callActivityOnNewIntent(android.app.Activity,%20android.content.Intent)(https://developer.android.com/reference/android/app/Activity activity, https://developer.android.com/reference/android/content/Intent intent) `

Perform calling of an activity's `https://developer.android.com/reference/android/app/Activity#onNewIntent(android.content.Intent)` method.
` void` ` https://developer.android.com/reference/android/app/Instrumentation#callActivityOnPause(android.app.Activity)(https://developer.android.com/reference/android/app/Activity activity) `

Perform calling of an activity's `https://developer.android.com/reference/android/app/Activity#onPause()` method.
` void` ` https://developer.android.com/reference/android/app/Instrumentation#callActivityOnPictureInPictureRequested(android.app.Activity)(https://developer.android.com/reference/android/app/Activity activity) `

Perform calling of an activity's `https://developer.android.com/reference/android/app/Activity#onPictureInPictureRequested()` method.
` void` ` https://developer.android.com/reference/android/app/Instrumentation#callActivityOnPostCreate(android.app.Activity,%20android.os.Bundle,%20android.os.PersistableBundle)(https://developer.android.com/reference/android/app/Activity activity, https://developer.android.com/reference/android/os/Bundle savedInstanceState, https://developer.android.com/reference/android/os/PersistableBundle persistentState) `

Perform calling of an activity's `https://developer.android.com/reference/android/app/Activity#onPostCreate(android.os.Bundle)` method.
` void` ` https://developer.android.com/reference/android/app/Instrumentation#callActivityOnPostCreate(android.app.Activity,%20android.os.Bundle)(https://developer.android.com/reference/android/app/Activity activity, https://developer.android.com/reference/android/os/Bundle savedInstanceState) `

Perform calling of an activity's `https://developer.android.com/reference/android/app/Activity#onPostCreate(android.os.Bundle)` method.
` void` ` https://developer.android.com/reference/android/app/Instrumentation#callActivityOnRestart(android.app.Activity)(https://developer.android.com/reference/android/app/Activity activity) `

Perform calling of an activity's `https://developer.android.com/reference/android/app/Activity#onRestart()` method.
` void` ` https://developer.android.com/reference/android/app/Instrumentation#callActivityOnRestoreInstanceState(android.app.Activity,%20android.os.Bundle)(https://developer.android.com/reference/android/app/Activity activity, https://developer.android.com/reference/android/os/Bundle savedInstanceState) `

Perform calling of an activity's `https://developer.android.com/reference/android/app/Activity#onRestoreInstanceState(android.os.Bundle)` method.
` void` ` https://developer.android.com/reference/android/app/Instrumentation#callActivityOnRestoreInstanceState(android.app.Activity,%20android.os.Bundle,%20android.os.PersistableBundle)(https://developer.android.com/reference/android/app/Activity activity, https://developer.android.com/reference/android/os/Bundle savedInstanceState, https://developer.android.com/reference/android/os/PersistableBundle persistentState) `

Perform calling of an activity's `https://developer.android.com/reference/android/app/Activity#onRestoreInstanceState(android.os.Bundle)` method.
` void` ` https://developer.android.com/reference/android/app/Instrumentation#callActivityOnResume(android.app.Activity)(https://developer.android.com/reference/android/app/Activity activity) `

Perform calling of an activity's `https://developer.android.com/reference/android/app/Activity#onResume()` method.
` void` ` https://developer.android.com/reference/android/app/Instrumentation#callActivityOnSaveInstanceState(android.app.Activity,%20android.os.Bundle,%20android.os.PersistableBundle)(https://developer.android.com/reference/android/app/Activity activity, https://developer.android.com/reference/android/os/Bundle outState, https://developer.android.com/reference/android/os/PersistableBundle outPersistentState) `

Perform calling of an activity's `https://developer.android.com/reference/android/app/Activity#onSaveInstanceState(android.os.Bundle)` method.
` void` ` https://developer.android.com/reference/android/app/Instrumentation#callActivityOnSaveInstanceState(android.app.Activity,%20android.os.Bundle)(https://developer.android.com/reference/android/app/Activity activity, https://developer.android.com/reference/android/os/Bundle outState) `

Perform calling of an activity's `https://developer.android.com/reference/android/app/Activity#onSaveInstanceState(android.os.Bundle)` method.
` void` ` https://developer.android.com/reference/android/app/Instrumentation#callActivityOnStart(android.app.Activity)(https://developer.android.com/reference/android/app/Activity activity) `

Perform calling of an activity's `https://developer.android.com/reference/android/app/Activity#onStart()` method.
` void` ` https://developer.android.com/reference/android/app/Instrumentation#callActivityOnStop(android.app.Activity)(https://developer.android.com/reference/android/app/Activity activity) `

Perform calling of an activity's `https://developer.android.com/reference/android/app/Activity#onStop()` method.
` void` ` https://developer.android.com/reference/android/app/Instrumentation#callActivityOnUserLeaving(android.app.Activity)(https://developer.android.com/reference/android/app/Activity activity) `

Perform calling of an activity's `https://developer.android.com/reference/android/app/Activity#onUserLeaveHint()` method.
` void` ` https://developer.android.com/reference/android/app/Instrumentation#callApplicationOnCreate(android.app.Application)(https://developer.android.com/reference/android/app/Application app) `

Perform calling of the application's `https://developer.android.com/reference/android/app/Application#onCreate()` method.
` boolean` ` https://developer.android.com/reference/android/app/Instrumentation#checkMonitorHit(android.app.Instrumentation.ActivityMonitor,%20int)(https://developer.android.com/reference/android/app/Instrumentation.ActivityMonitor monitor, int minHits) `

Test whether an existing `https://developer.android.com/reference/android/app/Instrumentation.ActivityMonitor` has been hit.
` void` ` https://developer.android.com/reference/android/app/Instrumentation#endPerformanceSnapshot()() ` ` void` ` https://developer.android.com/reference/android/app/Instrumentation#finish(int,%20android.os.Bundle)(int resultCode, https://developer.android.com/reference/android/os/Bundle results) `

Terminate instrumentation of the application.
` https://developer.android.com/reference/android/os/Bundle` ` https://developer.android.com/reference/android/app/Instrumentation#getAllocCounts()() `

Returns a bundle with the current results from the allocation counting.
` https://developer.android.com/reference/android/os/Bundle` ` https://developer.android.com/reference/android/app/Instrumentation#getBinderCounts()() `

Returns a bundle with the counts for various binder counts for this process.
` https://developer.android.com/reference/android/content/ComponentName` ` https://developer.android.com/reference/android/app/Instrumentation#getComponentName()() `

Returns complete component name of this instrumentation.
` https://developer.android.com/reference/android/content/Context` ` https://developer.android.com/reference/android/app/Instrumentation#getContext()() `

Return the Context of this instrumentation's package.
` https://developer.android.com/reference/java/lang/String` ` https://developer.android.com/reference/android/app/Instrumentation#getProcessName()() `

Return the name of the process this instrumentation is running in.
` https://developer.android.com/reference/android/content/Context` ` https://developer.android.com/reference/android/app/Instrumentation#getTargetContext()() `

Return a Context for the target application being instrumented.
` https://developer.android.com/reference/android/app/UiAutomation` ` https://developer.android.com/reference/android/app/Instrumentation#getUiAutomation(int)(int flags) `

Gets the `https://developer.android.com/reference/android/app/UiAutomation` instance with flags set.
` https://developer.android.com/reference/android/app/UiAutomation` ` https://developer.android.com/reference/android/app/Instrumentation#getUiAutomation()() `

Gets the `https://developer.android.com/reference/android/app/UiAutomation` instance with no flags set.
` boolean` ` https://developer.android.com/reference/android/app/Instrumentation#invokeContextMenuAction(android.app.Activity,%20int,%20int)(https://developer.android.com/reference/android/app/Activity targetActivity, int id, int flag) `

Show the context menu for the currently focused view and executes a particular context menu item.
` boolean` ` https://developer.android.com/reference/android/app/Instrumentation#invokeMenuActionSync(android.app.Activity,%20int,%20int)(https://developer.android.com/reference/android/app/Activity targetActivity, int id, int flag) `

Execute a particular menu item.
` boolean` ` https://developer.android.com/reference/android/app/Instrumentation#isProfiling()() `

Check whether this instrumentation was started with profiling enabled.
` https://developer.android.com/reference/android/app/Activity` ` https://developer.android.com/reference/android/app/Instrumentation#newActivity(java.lang.Class<?>,%20android.content.Context,%20android.os.IBinder,%20android.app.Application,%20android.content.Intent,%20android.content.pm.ActivityInfo,%20java.lang.CharSequence,%20android.app.Activity,%20java.lang.String,%20java.lang.Object)(https://developer.android.com/reference/java/lang/Class<?> clazz, https://developer.android.com/reference/android/content/Context context, https://developer.android.com/reference/android/os/IBinder token, https://developer.android.com/reference/android/app/Application application, https://developer.android.com/reference/android/content/Intent intent, https://developer.android.com/reference/android/content/pm/ActivityInfo info, https://developer.android.com/reference/java/lang/CharSequence title, https://developer.android.com/reference/android/app/Activity parent, https://developer.android.com/reference/java/lang/String id, https://developer.android.com/reference/java/lang/Object lastNonConfigurationInstance) `

Perform instantiation of an `https://developer.android.com/reference/android/app/Activity` object.
` https://developer.android.com/reference/android/app/Activity` ` https://developer.android.com/reference/android/app/Instrumentation#newActivity(java.lang.ClassLoader,%20java.lang.String,%20android.content.Intent)(https://developer.android.com/reference/java/lang/ClassLoader cl, https://developer.android.com/reference/java/lang/String className, https://developer.android.com/reference/android/content/Intent intent) `

Perform instantiation of the process's `https://developer.android.com/reference/android/app/Activity` object.
` https://developer.android.com/reference/android/app/Application` ` https://developer.android.com/reference/android/app/Instrumentation#newApplication(java.lang.ClassLoader,%20java.lang.String,%20android.content.Context)(https://developer.android.com/reference/java/lang/ClassLoader cl, https://developer.android.com/reference/java/lang/String className, https://developer.android.com/reference/android/content/Context context) `

Perform instantiation of the process's `https://developer.android.com/reference/android/app/Application` object.
` static https://developer.android.com/reference/android/app/Application` ` https://developer.android.com/reference/android/app/Instrumentation#newApplication(java.lang.Class<?>,%20android.content.Context)(https://developer.android.com/reference/java/lang/Class<?> clazz, https://developer.android.com/reference/android/content/Context context) `

Perform instantiation of the process's `https://developer.android.com/reference/android/app/Application` object.
` void` ` https://developer.android.com/reference/android/app/Instrumentation#onCreate(android.os.Bundle)(https://developer.android.com/reference/android/os/Bundle arguments) `

Called when the instrumentation is starting, before any application code has been loaded.
` void` ` https://developer.android.com/reference/android/app/Instrumentation#onDestroy()() `

Called when the instrumented application is stopping, after all of the normal application cleanup has occurred.
` boolean` ` https://developer.android.com/reference/android/app/Instrumentation#onException(java.lang.Object,%20java.lang.Throwable)(https://developer.android.com/reference/java/lang/Object obj, https://developer.android.com/reference/java/lang/Throwable e) `

This is called whenever the system captures an unhandled exception that was thrown by the application.
` void` ` https://developer.android.com/reference/android/app/Instrumentation#onStart()() `

Method where the instrumentation thread enters execution.
` void` ` https://developer.android.com/reference/android/app/Instrumentation#removeMonitor(android.app.Instrumentation.ActivityMonitor)(https://developer.android.com/reference/android/app/Instrumentation.ActivityMonitor monitor) `

Remove an `https://developer.android.com/reference/android/app/Instrumentation.ActivityMonitor` that was previously added with `https://developer.android.com/reference/android/app/Instrumentation#addMonitor(android.app.Instrumentation.ActivityMonitor)`.
` void` ` https://developer.android.com/reference/android/app/Instrumentation#resetInTouchMode()() `

Resets the `https://developer.android.com/reference/android/app/Instrumentation#setInTouchMode(boolean)` to the device default.
` void` ` https://developer.android.com/reference/android/app/Instrumentation#runOnMainSync(java.lang.Runnable)(https://developer.android.com/reference/java/lang/Runnable runner) `

Execute a call on the application's main thread, blocking until it is complete.
` void` ` https://developer.android.com/reference/android/app/Instrumentation#sendCharacterSync(int)(int keyCode) `

Sends up and down key events with the given key code to the currently focused window, and waits for it to be processed.
` void` ` https://developer.android.com/reference/android/app/Instrumentation#sendKeyDownUpSync(int)(int keyCode) `

Sends up and down key events with the given key code to the currently focused window, and waits for it to be processed.
` void` ` https://developer.android.com/reference/android/app/Instrumentation#sendKeySync(android.view.KeyEvent)(https://developer.android.com/reference/android/view/KeyEvent event) `

Sends a key event to the currently focused window, and waits for it to be processed.
` void` ` https://developer.android.com/reference/android/app/Instrumentation#sendPointerSync(android.view.MotionEvent)(https://developer.android.com/reference/android/view/MotionEvent event) `

Dispatches a pointer event into a window owned by the instrumented application, and waits for it to be processed.
` void` ` https://developer.android.com/reference/android/app/Instrumentation#sendStatus(int,%20android.os.Bundle)(int resultCode, https://developer.android.com/reference/android/os/Bundle results) `

Provide a status report about the application.
` void` ` https://developer.android.com/reference/android/app/Instrumentation#sendStringSync(java.lang.String)(https://developer.android.com/reference/java/lang/String text) `

Sends the key events that result in the given text being typed into the currently focused window, and waits for it to be processed.
` void` ` https://developer.android.com/reference/android/app/Instrumentation#sendTrackballEventSync(android.view.MotionEvent)(https://developer.android.com/reference/android/view/MotionEvent event) `

Dispatches a trackball event into the currently focused window, and waits for it to be processed.
` void` ` https://developer.android.com/reference/android/app/Instrumentation#setAutomaticPerformanceSnapshots()() ` ` void` ` https://developer.android.com/reference/android/app/Instrumentation#setInTouchMode(boolean)(boolean inTouch) `

Force the global system in or out of touch mode.
` void` ` https://developer.android.com/reference/android/app/Instrumentation#start()() `

Create and start a new thread in which to run instrumentation.
` https://developer.android.com/reference/android/app/Activity` ` https://developer.android.com/reference/android/app/Instrumentation#startActivitySync(android.content.Intent,%20android.os.Bundle)(https://developer.android.com/reference/android/content/Intent intent, https://developer.android.com/reference/android/os/Bundle options) `

Start a new activity and wait for it to begin running before returning.
` https://developer.android.com/reference/android/app/Activity` ` https://developer.android.com/reference/android/app/Instrumentation#startActivitySync(android.content.Intent)(https://developer.android.com/reference/android/content/Intent intent) `

Start a new activity and wait for it to begin running before returning.
` void` ` https://developer.android.com/reference/android/app/Instrumentation#startAllocCounting()() ` ` void` ` https://developer.android.com/reference/android/app/Instrumentation#startPerformanceSnapshot()() ` ` void` ` https://developer.android.com/reference/android/app/Instrumentation#startProfiling()() `

This method will start profiling if isProfiling() returns true.
` void` ` https://developer.android.com/reference/android/app/Instrumentation#stopAllocCounting()() ` ` void` ` https://developer.android.com/reference/android/app/Instrumentation#stopProfiling()() `

Stops profiling if isProfiling() returns true.
` void` ` https://developer.android.com/reference/android/app/Instrumentation#waitForIdle(java.lang.Runnable)(https://developer.android.com/reference/java/lang/Runnable recipient) `

Schedule a callback for when the application's main thread goes idle (has no more events to process).
` void` ` https://developer.android.com/reference/android/app/Instrumentation#waitForIdleSync()() `

Synchronously wait for the application to be idle.
` https://developer.android.com/reference/android/app/Activity` ` https://developer.android.com/reference/android/app/Instrumentation#waitForMonitor(android.app.Instrumentation.ActivityMonitor)(https://developer.android.com/reference/android/app/Instrumentation.ActivityMonitor monitor) `

Wait for an existing `https://developer.android.com/reference/android/app/Instrumentation.ActivityMonitor` to be hit.
` https://developer.android.com/reference/android/app/Activity` ` https://developer.android.com/reference/android/app/Instrumentation#waitForMonitorWithTimeout(android.app.Instrumentation.ActivityMonitor,%20long)(https://developer.android.com/reference/android/app/Instrumentation.ActivityMonitor monitor, long timeOut) `

Wait for an existing `https://developer.android.com/reference/android/app/Instrumentation.ActivityMonitor` to be hit till the timeout expires.
From class ` https://developer.android.com/reference/java/lang/Object ` ` https://developer.android.com/reference/java/lang/Object` ` https://developer.android.com/reference/java/lang/Object#clone()() `

Creates and returns a copy of this object.
` boolean` ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) `

Indicates whether some other object is "equal to" this one.
` void` ` https://developer.android.com/reference/java/lang/Object#finalize()() `

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
` final https://developer.android.com/reference/java/lang/Class<?>` ` https://developer.android.com/reference/java/lang/Object#getClass()() `

Returns the runtime class of this `Object`.
` int` ` https://developer.android.com/reference/java/lang/Object#hashCode()() `

Returns a hash code value for the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#notify()() `

Wakes up a single thread that is waiting on this object's monitor.
` final void` ` https://developer.android.com/reference/java/lang/Object#notifyAll()() `

Wakes up all threads that are waiting on this object's monitor.
` https://developer.android.com/reference/java/lang/String` ` https://developer.android.com/reference/java/lang/Object#toString()() `

Returns a string representation of the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait()() `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*.
From interface ` https://developer.android.com/reference/android/test/TestSuiteProvider ` ` abstract TestSuite` ` https://developer.android.com/reference/android/test/TestSuiteProvider#getTestSuite()() `

## Constants

### REPORT_KEY_NAME_CLASS

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String REPORT_KEY_NAME_CLASS
```

If included in the status or final bundle sent to an IInstrumentationWatcher, this key identifies the name of the current test class. This is sent with any status message describing a specific test being started or completed.

<br />

Constant Value: "class"

### REPORT_KEY_NAME_TEST

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String REPORT_KEY_NAME_TEST
```

If included in the status or final bundle sent to an IInstrumentationWatcher, this key identifies the name of the current test. This is sent with any status message describing a specific test being started or completed.

<br />

Constant Value: "test"

### REPORT_KEY_NUM_CURRENT

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String REPORT_KEY_NUM_CURRENT
```

If included in the status or final bundle sent to an IInstrumentationWatcher, this key identifies the sequence number of the current test. This is sent with any status message describing a specific test being started or completed.

<br />

Constant Value: "current"

### REPORT_KEY_NUM_TOTAL

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String REPORT_KEY_NUM_TOTAL
```

If included in the status or final bundle sent to an IInstrumentationWatcher, this key identifies the total number of tests that are being run. This is sent with all status messages.

<br />

Constant Value: "numtests"

### REPORT_KEY_STACK

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String REPORT_KEY_STACK
```

If included in the status bundle sent to an IInstrumentationWatcher, this key identifies a stack trace describing an error or failure. This is sent with any status message describing a specific test being completed.

<br />

Constant Value: "stack"

### REPORT_VALUE_ID

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String REPORT_VALUE_ID
```

This value, if stored with key `https://developer.android.com/reference/android/app/Instrumentation#REPORT_KEY_IDENTIFIER`, identifies InstrumentationTestRunner as the source of the report. This is sent with all status messages.

<br />

Constant Value: "InstrumentationTestRunner"

### REPORT_VALUE_RESULT_ERROR

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int REPORT_VALUE_RESULT_ERROR
```

The test completed with an error.

<br />

Constant Value: -1 (0xffffffff)

### REPORT_VALUE_RESULT_FAILURE

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int REPORT_VALUE_RESULT_FAILURE
```

The test completed with a failure.

<br />

Constant Value: -2 (0xfffffffe)

### REPORT_VALUE_RESULT_OK

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int REPORT_VALUE_RESULT_OK
```

The test completed successfully.

<br />

Constant Value: 0 (0x00000000)

### REPORT_VALUE_RESULT_START

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int REPORT_VALUE_RESULT_START
```

The test is starting.

<br />

Constant Value: 1 (0x00000001)

## Public constructors

### InstrumentationTestRunner

```
public InstrumentationTestRunner ()
```

<br />

<br />

## Public methods

### getAllTests

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public TestSuite getAllTests ()
```

Override this to define all of the tests to run in your package.

<br />

| Returns ||
|---|---|
| `TestSuite` | <br /> |

### getArguments

Added in [API level 18](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)   
Deprecated in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Bundle getArguments ()
```

Get the arguments passed to this instrumentation.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/os/Bundle` | the Bundle object <br /> |

### getLoader

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public ClassLoader getLoader ()
```

Override this to provide access to the class loader of your package.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/ClassLoader` | <br /> |

### getTestSuite

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public TestSuite getTestSuite ()
```

<br />

<br />

| Returns ||
|---|---|
| `TestSuite` | <br /> |

### onCreate

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void onCreate (Bundle arguments)
```

Called when the instrumentation is starting, before any application code has been loaded. Usually this will be implemented to simply call `https://developer.android.com/reference/android/app/Instrumentation#start()` to begin the instrumentation thread, which will then continue execution in `https://developer.android.com/reference/android/app/Instrumentation#onStart()`.

If you do not need your own thread -- that is you are writing your instrumentation to be completely asynchronous (returning to the event loop so that the application can run), you can simply begin your instrumentation here, for example call `https://developer.android.com/reference/android/content/Context#startActivity(android.content.Intent)` to begin the appropriate first activity of the application.

<br />

| Parameters ||
|---|---|
| `arguments` | `Bundle`: Any additional arguments that were supplied when the instrumentation was started. <br /> |

### onStart

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void onStart ()
```

Method where the instrumentation thread enters execution. This allows you to run your instrumentation code in a separate thread than the application, so that it can perform blocking operation such as `https://developer.android.com/reference/android/app/Instrumentation#sendKeySync(android.view.KeyEvent)` or `https://developer.android.com/reference/android/app/Instrumentation#startActivitySync(android.content.Intent)`.

You will typically want to call finish() when this function is done, to end your instrumentation.

<br />

## Protected methods

### addTestListener

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
protected void addTestListener (TestListener listener)
```

Add a `https://developer.android.com/`

<br />

| Parameters ||
|---|---|
| `listener` | `TestListener` <br /> |

### getAndroidTestRunner

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
protected AndroidTestRunner getAndroidTestRunner ()
```

<br />

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/test/AndroidTestRunner` | <br /> |