# UiAutomatorInstrumentationTestRunner

Artifact: [androidx.test.uiautomator:uiautomator](https://developer.android.com/jetpack/androidx/releases/test-uiautomator) [View Source](https://cs.android.com/search?q=file:androidx/test/uiautomator/UiAutomatorInstrumentationTestRunner.java+class:androidx.test.uiautomator.UiAutomatorInstrumentationTestRunner) Added in [2.2.0](https://developer.android.com/jetpack/androidx/releases/test-uiautomator#2.2.0) Deprecated in [2.3.0](https://developer.android.com/jetpack/androidx/releases/test-uiautomator#2.3.0)

*** ** * ** ***


```
public class UiAutomatorInstrumentationTestRunner extends InstrumentationTestRunner
```

<br />

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

*** ** * ** ***

> [!CAUTION]
> **This class is deprecated.**   
>
> as it only handles deprecated `https://developer.android.com/reference/androidx/test/uiautomator/UiAutomatorTestCase`s. You should use `https://developer.android.com/reference/androidx/test/uiautomator/UiDevice#getInstance(android.app.Instrumentation)` from any test class as long as you have access to an `https://developer.android.com/reference/android/app/Instrumentation.html` instance.

Test runner for `https://developer.android.com/reference/androidx/test/uiautomator/UiAutomatorTestCase`s. Such tests are executed on the device and have access to an applications context.

## Summary

| ### Public constructors |
|---|
| `[UiAutomatorInstrumentationTestRunner](https://developer.android.com/reference/androidx/test/uiautomator/UiAutomatorInstrumentationTestRunner#UiAutomatorInstrumentationTestRunner())()` **This method is deprecated.** Deprecated in Java |

| ### Protected methods |
|---|---|
| `https://developer.android.com/reference/android/test/AndroidTestRunner.html` | `[getAndroidTestRunner](https://developer.android.com/reference/androidx/test/uiautomator/UiAutomatorInstrumentationTestRunner#getAndroidTestRunner())()` **This method is deprecated.** |
| `void` | `[initializeUiAutomatorTest](https://developer.android.com/reference/androidx/test/uiautomator/UiAutomatorInstrumentationTestRunner#initializeUiAutomatorTest(androidx.test.uiautomator.UiAutomatorTestCase))(https://developer.android.com/reference/androidx/test/uiautomator/UiAutomatorTestCase test)` **This method is deprecated.** Deprecated in Java |

### Inherited Constants

From [android.app.Instrumentation](https://developer.android.com/reference/android/app/Instrumentation.html) `static final https://developer.android.com/reference/java/lang/String.html` `https://developer.android.com/reference/android/app/Instrumentation.html#REPORT_KEY_IDENTIFIER = "id"`

**This field is deprecated.** Deprecated in Java
`static final https://developer.android.com/reference/java/lang/String.html` `https://developer.android.com/reference/android/app/Instrumentation.html#REPORT_KEY_STREAMRESULT = "stream"`

**This field is deprecated.** Deprecated in Java
From [android.test.InstrumentationTestRunner](https://developer.android.com/reference/android/test/InstrumentationTestRunner.html) `static final https://developer.android.com/reference/java/lang/String.html` `https://developer.android.com/reference/android/test/InstrumentationTestRunner.html#REPORT_KEY_NAME_CLASS = "class"`

**This field is deprecated.**
`static final https://developer.android.com/reference/java/lang/String.html` `https://developer.android.com/reference/android/test/InstrumentationTestRunner.html#REPORT_KEY_NAME_TEST = "test"`

**This field is deprecated.**
`static final https://developer.android.com/reference/java/lang/String.html` `https://developer.android.com/reference/android/test/InstrumentationTestRunner.html#REPORT_KEY_NUM_CURRENT = "current"`

**This field is deprecated.**
`static final https://developer.android.com/reference/java/lang/String.html` `https://developer.android.com/reference/android/test/InstrumentationTestRunner.html#REPORT_KEY_NUM_TOTAL = "numtests"`

**This field is deprecated.**
`static final https://developer.android.com/reference/java/lang/String.html` `https://developer.android.com/reference/android/test/InstrumentationTestRunner.html#REPORT_KEY_STACK = "stack"`

**This field is deprecated.**
`static final https://developer.android.com/reference/java/lang/String.html` `https://developer.android.com/reference/android/test/InstrumentationTestRunner.html#REPORT_VALUE_ID = "InstrumentationTestRunner"`

**This field is deprecated.**
`static final int` `https://developer.android.com/reference/android/test/InstrumentationTestRunner.html#REPORT_VALUE_RESULT_ERROR = -1`

**This field is deprecated.**
`static final int` `https://developer.android.com/reference/android/test/InstrumentationTestRunner.html#REPORT_VALUE_RESULT_FAILURE = -2`

**This field is deprecated.**
`static final int` `https://developer.android.com/reference/android/test/InstrumentationTestRunner.html#REPORT_VALUE_RESULT_OK = 0`

**This field is deprecated.**
`static final int` `https://developer.android.com/reference/android/test/InstrumentationTestRunner.html#REPORT_VALUE_RESULT_START = 1`

**This field is deprecated.**

### Inherited methods

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

**This method is deprecated.** Deprecated in Java
`void` `[addMonitor](https://developer.android.com/reference/android/app/Instrumentation.html#addMonitor(android.app.Instrumentation.ActivityMonitor))(https://developer.android.com/reference/android/app/Instrumentation.ActivityMonitor.html monitor)`

**This method is deprecated.** Deprecated in Java
`https://developer.android.com/reference/android/app/Instrumentation.ActivityMonitor.html` `[addMonitor](https://developer.android.com/reference/android/app/Instrumentation.html#addMonitor(android.content.IntentFilter, android.app.Instrumentation.ActivityResult, boolean))(
https://developer.android.com/reference/android/content/IntentFilter.html filter,
https://developer.android.com/reference/android/app/Instrumentation.ActivityResult.html result,
boolean block
)`

**This method is deprecated.** Deprecated in Java
`void` `[addResults](https://developer.android.com/reference/android/app/Instrumentation.html#addResults(android.os.Bundle))(https://developer.android.com/reference/android/os/Bundle.html results)`

**This method is deprecated.** Deprecated in Java
`void` `[callActivityOnCreate](https://developer.android.com/reference/android/app/Instrumentation.html#callActivityOnCreate(android.app.Activity, android.os.Bundle))(https://developer.android.com/reference/android/app/Activity.html activity, https://developer.android.com/reference/android/os/Bundle.html icicle)`

**This method is deprecated.** Deprecated in Java
`void` `[callActivityOnDestroy](https://developer.android.com/reference/android/app/Instrumentation.html#callActivityOnDestroy(android.app.Activity))(https://developer.android.com/reference/android/app/Activity.html activity)`

**This method is deprecated.** Deprecated in Java
`void` `[callActivityOnNewIntent](https://developer.android.com/reference/android/app/Instrumentation.html#callActivityOnNewIntent(android.app.Activity, android.content.Intent))(https://developer.android.com/reference/android/app/Activity.html activity, https://developer.android.com/reference/android/content/Intent.html intent)`

**This method is deprecated.** Deprecated in Java
`void` `[callActivityOnPause](https://developer.android.com/reference/android/app/Instrumentation.html#callActivityOnPause(android.app.Activity))(https://developer.android.com/reference/android/app/Activity.html activity)`

**This method is deprecated.** Deprecated in Java
`void` `[callActivityOnPictureInPictureRequested](https://developer.android.com/reference/android/app/Instrumentation.html#callActivityOnPictureInPictureRequested(android.app.Activity))(https://developer.android.com/reference/android/app/Activity.html activity)`

**This method is deprecated.** Deprecated in Java
`void` `[callActivityOnPostCreate](https://developer.android.com/reference/android/app/Instrumentation.html#callActivityOnPostCreate(android.app.Activity, android.os.Bundle))(https://developer.android.com/reference/android/app/Activity.html activity, https://developer.android.com/reference/android/os/Bundle.html savedInstanceState)`

**This method is deprecated.** Deprecated in Java
`void` `[callActivityOnRestart](https://developer.android.com/reference/android/app/Instrumentation.html#callActivityOnRestart(android.app.Activity))(https://developer.android.com/reference/android/app/Activity.html activity)`

**This method is deprecated.** Deprecated in Java
`void` `[callActivityOnRestoreInstanceState](https://developer.android.com/reference/android/app/Instrumentation.html#callActivityOnRestoreInstanceState(android.app.Activity, android.os.Bundle))(
https://developer.android.com/reference/android/app/Activity.html activity,
https://developer.android.com/reference/android/os/Bundle.html savedInstanceState
)`

**This method is deprecated.** Deprecated in Java
`void` `[callActivityOnResume](https://developer.android.com/reference/android/app/Instrumentation.html#callActivityOnResume(android.app.Activity))(https://developer.android.com/reference/android/app/Activity.html activity)`

**This method is deprecated.** Deprecated in Java
`void` `[callActivityOnSaveInstanceState](https://developer.android.com/reference/android/app/Instrumentation.html#callActivityOnSaveInstanceState(android.app.Activity, android.os.Bundle))(https://developer.android.com/reference/android/app/Activity.html activity, https://developer.android.com/reference/android/os/Bundle.html outState)`

**This method is deprecated.** Deprecated in Java
`void` `[callActivityOnStart](https://developer.android.com/reference/android/app/Instrumentation.html#callActivityOnStart(android.app.Activity))(https://developer.android.com/reference/android/app/Activity.html activity)`

**This method is deprecated.** Deprecated in Java
`void` `[callActivityOnStop](https://developer.android.com/reference/android/app/Instrumentation.html#callActivityOnStop(android.app.Activity))(https://developer.android.com/reference/android/app/Activity.html activity)`

**This method is deprecated.** Deprecated in Java
`void` `[callActivityOnUserLeaving](https://developer.android.com/reference/android/app/Instrumentation.html#callActivityOnUserLeaving(android.app.Activity))(https://developer.android.com/reference/android/app/Activity.html activity)`

**This method is deprecated.** Deprecated in Java
`void` `[callApplicationOnCreate](https://developer.android.com/reference/android/app/Instrumentation.html#callApplicationOnCreate(android.app.Application))(https://developer.android.com/reference/android/app/Application.html app)`

**This method is deprecated.** Deprecated in Java
`boolean` `[checkMonitorHit](https://developer.android.com/reference/android/app/Instrumentation.html#checkMonitorHit(android.app.Instrumentation.ActivityMonitor, int))(https://developer.android.com/reference/android/app/Instrumentation.ActivityMonitor.html monitor, int minHits)`

**This method is deprecated.** Deprecated in Java
`void` `[endPerformanceSnapshot](https://developer.android.com/reference/android/app/Instrumentation.html#endPerformanceSnapshot())()`

**This method is deprecated.** Deprecated in Java
`void` `[finish](https://developer.android.com/reference/android/app/Instrumentation.html#finish(int, android.os.Bundle))(int resultCode, https://developer.android.com/reference/android/os/Bundle.html results)`

**This method is deprecated.** Deprecated in Java
`https://developer.android.com/reference/android/os/Bundle.html` `[getAllocCounts](https://developer.android.com/reference/android/app/Instrumentation.html#getAllocCounts())()`

**This method is deprecated.** Deprecated in Java
`https://developer.android.com/reference/android/os/Bundle.html` `[getBinderCounts](https://developer.android.com/reference/android/app/Instrumentation.html#getBinderCounts())()`

**This method is deprecated.** Deprecated in Java
`https://developer.android.com/reference/android/content/ComponentName.html` `[getComponentName](https://developer.android.com/reference/android/app/Instrumentation.html#getComponentName())()`

**This method is deprecated.** Deprecated in Java
`https://developer.android.com/reference/android/content/Context.html` `[getContext](https://developer.android.com/reference/android/app/Instrumentation.html#getContext())()`

**This method is deprecated.** Deprecated in Java
`https://developer.android.com/reference/java/lang/String.html` `[getProcessName](https://developer.android.com/reference/android/app/Instrumentation.html#getProcessName())()`

**This method is deprecated.** Deprecated in Java
`https://developer.android.com/reference/android/content/Context.html` `[getTargetContext](https://developer.android.com/reference/android/app/Instrumentation.html#getTargetContext())()`

**This method is deprecated.** Deprecated in Java
`https://developer.android.com/reference/android/app/UiAutomation.html` `[getUiAutomation](https://developer.android.com/reference/android/app/Instrumentation.html#getUiAutomation())()`

**This method is deprecated.** Deprecated in Java
`boolean` `[invokeContextMenuAction](https://developer.android.com/reference/android/app/Instrumentation.html#invokeContextMenuAction(android.app.Activity, int, int))(https://developer.android.com/reference/android/app/Activity.html targetActivity, int id, int flag)`

**This method is deprecated.** Deprecated in Java
`boolean` `[invokeMenuActionSync](https://developer.android.com/reference/android/app/Instrumentation.html#invokeMenuActionSync(android.app.Activity, int, int))(https://developer.android.com/reference/android/app/Activity.html targetActivity, int id, int flag)`

**This method is deprecated.** Deprecated in Java
`boolean` `[isProfiling](https://developer.android.com/reference/android/app/Instrumentation.html#isProfiling())()`

**This method is deprecated.** Deprecated in Java
`https://developer.android.com/reference/android/app/Activity.html` `[newActivity](https://developer.android.com/reference/android/app/Instrumentation.html#newActivity(java.lang.Class&lt;?&gt;, android.content.Context, android.os.IBinder, android.app.Application, android.content.Intent, android.content.pm.ActivityInfo, java.lang.CharSequence, android.app.Activity, java.lang.String, java.lang.Object))(
https://developer.android.com/reference/java/lang/Class.html<@https://developer.android.com/reference/androidx/annotation/NonNull ?> clazz,
https://developer.android.com/reference/android/content/Context.html context,
https://developer.android.com/reference/android/os/IBinder.html token,
https://developer.android.com/reference/android/app/Application.html application,
https://developer.android.com/reference/android/content/Intent.html intent,
https://developer.android.com/reference/android/content/pm/ActivityInfo.html info,
https://developer.android.com/reference/java/lang/CharSequence.html title,
https://developer.android.com/reference/android/app/Activity.html parent,
https://developer.android.com/reference/java/lang/String.html id,
https://developer.android.com/reference/java/lang/Object.html lastNonConfigurationInstance
)`

**This method is deprecated.** Deprecated in Java
`static https://developer.android.com/reference/android/app/Application.html` `[newApplication](https://developer.android.com/reference/android/app/Instrumentation.html#newApplication(java.lang.Class&lt;?&gt;, android.content.Context))(https://developer.android.com/reference/java/lang/Class.html<@https://developer.android.com/reference/androidx/annotation/NonNull ?> clazz, https://developer.android.com/reference/android/content/Context.html context)`

**This method is deprecated.** Deprecated in Java
`void` `[onDestroy](https://developer.android.com/reference/android/app/Instrumentation.html#onDestroy())()`

**This method is deprecated.** Deprecated in Java
`boolean` `[onException](https://developer.android.com/reference/android/app/Instrumentation.html#onException(java.lang.Object, java.lang.Throwable))(https://developer.android.com/reference/java/lang/Object.html obj, https://developer.android.com/reference/java/lang/Throwable.html e)`

**This method is deprecated.** Deprecated in Java
`void` `[removeMonitor](https://developer.android.com/reference/android/app/Instrumentation.html#removeMonitor(android.app.Instrumentation.ActivityMonitor))(https://developer.android.com/reference/android/app/Instrumentation.ActivityMonitor.html monitor)`

**This method is deprecated.** Deprecated in Java
`void` `[resetInTouchMode](https://developer.android.com/reference/android/app/Instrumentation.html#resetInTouchMode())()`

**This method is deprecated.** Deprecated in Java
`void` `[runOnMainSync](https://developer.android.com/reference/android/app/Instrumentation.html#runOnMainSync(java.lang.Runnable))(https://developer.android.com/reference/java/lang/Runnable.html runner)`

**This method is deprecated.** Deprecated in Java
`void` `[sendCharacterSync](https://developer.android.com/reference/android/app/Instrumentation.html#sendCharacterSync(int))(int keyCode)`

**This method is deprecated.** Deprecated in Java
`void` `[sendKeyDownUpSync](https://developer.android.com/reference/android/app/Instrumentation.html#sendKeyDownUpSync(int))(int keyCode)`

**This method is deprecated.** Deprecated in Java
`void` `[sendKeySync](https://developer.android.com/reference/android/app/Instrumentation.html#sendKeySync(android.view.KeyEvent))(https://developer.android.com/reference/android/view/KeyEvent.html event)`

**This method is deprecated.** Deprecated in Java
`void` `[sendPointerSync](https://developer.android.com/reference/android/app/Instrumentation.html#sendPointerSync(android.view.MotionEvent))(https://developer.android.com/reference/android/view/MotionEvent.html event)`

**This method is deprecated.** Deprecated in Java
`void` `[sendStatus](https://developer.android.com/reference/android/app/Instrumentation.html#sendStatus(int, android.os.Bundle))(int resultCode, https://developer.android.com/reference/android/os/Bundle.html results)`

**This method is deprecated.** Deprecated in Java
`void` `[sendStringSync](https://developer.android.com/reference/android/app/Instrumentation.html#sendStringSync(java.lang.String))(https://developer.android.com/reference/java/lang/String.html text)`

**This method is deprecated.** Deprecated in Java
`void` `[sendTrackballEventSync](https://developer.android.com/reference/android/app/Instrumentation.html#sendTrackballEventSync(android.view.MotionEvent))(https://developer.android.com/reference/android/view/MotionEvent.html event)`

**This method is deprecated.** Deprecated in Java
`void` `[setAutomaticPerformanceSnapshots](https://developer.android.com/reference/android/app/Instrumentation.html#setAutomaticPerformanceSnapshots())()`

**This method is deprecated.** Deprecated in Java
`void` `[setInTouchMode](https://developer.android.com/reference/android/app/Instrumentation.html#setInTouchMode(boolean))(boolean inTouch)`

**This method is deprecated.** Deprecated in Java
`void` `[start](https://developer.android.com/reference/android/app/Instrumentation.html#start())()`

**This method is deprecated.** Deprecated in Java
`https://developer.android.com/reference/android/app/Activity.html` `[startActivitySync](https://developer.android.com/reference/android/app/Instrumentation.html#startActivitySync(android.content.Intent))(https://developer.android.com/reference/android/content/Intent.html intent)`

**This method is deprecated.** Deprecated in Java
`void` `[startAllocCounting](https://developer.android.com/reference/android/app/Instrumentation.html#startAllocCounting())()`

**This method is deprecated.**
`void` `[startPerformanceSnapshot](https://developer.android.com/reference/android/app/Instrumentation.html#startPerformanceSnapshot())()`

**This method is deprecated.** Deprecated in Java
`void` `[startProfiling](https://developer.android.com/reference/android/app/Instrumentation.html#startProfiling())()`

**This method is deprecated.** Deprecated in Java
`void` `[stopAllocCounting](https://developer.android.com/reference/android/app/Instrumentation.html#stopAllocCounting())()`

**This method is deprecated.**
`void` `[stopProfiling](https://developer.android.com/reference/android/app/Instrumentation.html#stopProfiling())()`

**This method is deprecated.** Deprecated in Java
`void` `[waitForIdle](https://developer.android.com/reference/android/app/Instrumentation.html#waitForIdle(java.lang.Runnable))(https://developer.android.com/reference/java/lang/Runnable.html recipient)`

**This method is deprecated.** Deprecated in Java
`void` `[waitForIdleSync](https://developer.android.com/reference/android/app/Instrumentation.html#waitForIdleSync())()`

**This method is deprecated.** Deprecated in Java
`https://developer.android.com/reference/android/app/Activity.html` `[waitForMonitor](https://developer.android.com/reference/android/app/Instrumentation.html#waitForMonitor(android.app.Instrumentation.ActivityMonitor))(https://developer.android.com/reference/android/app/Instrumentation.ActivityMonitor.html monitor)`

**This method is deprecated.** Deprecated in Java
`https://developer.android.com/reference/android/app/Activity.html` `[waitForMonitorWithTimeout](https://developer.android.com/reference/android/app/Instrumentation.html#waitForMonitorWithTimeout(android.app.Instrumentation.ActivityMonitor, long))(
https://developer.android.com/reference/android/app/Instrumentation.ActivityMonitor.html monitor,
long timeOut
)`

**This method is deprecated.** Deprecated in Java
From [android.test.InstrumentationTestRunner](https://developer.android.com/reference/android/test/InstrumentationTestRunner.html) `void` `[addTestListener](https://developer.android.com/reference/android/test/InstrumentationTestRunner.html#addTestListener(junit.framework.TestListener))(junit.framework.TestListener listener)`

**This method is deprecated.**
`junit.framework.TestSuite` `[getAllTests](https://developer.android.com/reference/android/test/InstrumentationTestRunner.html#getAllTests())()`

**This method is deprecated.**
`https://developer.android.com/reference/android/os/Bundle.html` `[getArguments](https://developer.android.com/reference/android/test/InstrumentationTestRunner.html#getArguments())()`

**This method is deprecated.**
`https://developer.android.com/reference/java/lang/ClassLoader.html` `[getLoader](https://developer.android.com/reference/android/test/InstrumentationTestRunner.html#getLoader())()`

**This method is deprecated.**
`junit.framework.TestSuite` `[getTestSuite](https://developer.android.com/reference/android/test/InstrumentationTestRunner.html#getTestSuite())()`

**This method is deprecated.**
`void` `[onCreate](https://developer.android.com/reference/android/test/InstrumentationTestRunner.html#onCreate(android.os.Bundle))(https://developer.android.com/reference/android/os/Bundle.html arguments)`

**This method is deprecated.**
`void` `[onStart](https://developer.android.com/reference/android/test/InstrumentationTestRunner.html#onStart())()`

**This method is deprecated.**

## Public constructors

### UiAutomatorInstrumentationTestRunner

Added in 2.2.0 Deprecated in 2.3.0

```
public [UiAutomatorInstrumentationTestRunner](https://developer.android.com/reference/androidx/test/uiautomator/UiAutomatorInstrumentationTestRunner#UiAutomatorInstrumentationTestRunner())()
```

> [!CAUTION]
> **This method is deprecated.**   
> Deprecated in Java

## Protected methods

### getAndroidTestRunner

Added in [2.2.0](https://developer.android.com/jetpack/androidx/releases/test-uiautomator#2.2.0) Deprecated in [2.3.0](https://developer.android.com/jetpack/androidx/releases/test-uiautomator#2.3.0)

```
protected AndroidTestRunner [getAndroidTestRunner](https://developer.android.com/reference/androidx/test/uiautomator/UiAutomatorInstrumentationTestRunner#getAndroidTestRunner())()
```

> [!CAUTION]
> **This method is deprecated.**   

### initializeUiAutomatorTest

Added in [2.2.0](https://developer.android.com/jetpack/androidx/releases/test-uiautomator#2.2.0) Deprecated in [2.3.0](https://developer.android.com/jetpack/androidx/releases/test-uiautomator#2.3.0)

```
protected void [initializeUiAutomatorTest](https://developer.android.com/reference/androidx/test/uiautomator/UiAutomatorInstrumentationTestRunner#initializeUiAutomatorTest(androidx.test.uiautomator.UiAutomatorTestCase))(UiAutomatorTestCase test)
```

> [!CAUTION]
> **This method is deprecated.**   
> Deprecated in Java

Perform initialization specific to UiAutomator test. It sets up the test case so that it can access the UiDevice and gives it access to the command line arguments.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/test/uiautomator/UiAutomatorTestCase test` | UiAutomatorTestCase to initialize. |