# UiAutomatorTestCase

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/UiAutomatorTestCase.java+class:androidx.test.uiautomator.UiAutomatorTestCase) Added in [2.2.0](https://developer.android.com/jetpack/androidx/releases/test-uiautomator#2.2.0) Deprecated in [2.2.0](https://developer.android.com/jetpack/androidx/releases/test-uiautomator#2.2.0)

*** ** * ** ***


```
class UiAutomatorTestCase : InstrumentationTestCase
```

<br />

|---|---|---|---|---|
| [kotlin.Any](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html) |||||
| ↳ | junit.framework.Assert ||||
|   | ↳ | junit.framework.TestCase |||
|   |   | ↳ | [android.test.InstrumentationTestCase](https://developer.android.com/reference/android/test/InstrumentationTestCase.html) ||
|   |   |   | ↳ | [androidx.test.uiautomator.UiAutomatorTestCase](https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiAutomatorTestCase) |

*** ** * ** ***

> [!CAUTION]
> **This class is deprecated.**   
>
> It is no longer necessary to extend UiAutomatorTestCase. You can use `https://developer.android.com/reference/kotlin/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.

UI Automator test case that is executed on the device.

## Summary

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

| ### Public functions |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/IAutomationSupport!` | `[getAutomationSupport](https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiAutomatorTestCase#getAutomationSupport())()` **This function is deprecated.** Use `https://developer.android.com/reference/android/app/Instrumentation.html#sendStatus(int, android.os.Bundle)` instead <br /> |
| `https://developer.android.com/reference/android/os/Bundle.html!` | `[getParams](https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiAutomatorTestCase#getParams())()` **This function is deprecated.** Deprecated in Java |
| `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiDevice!` | `[getUiDevice](https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiAutomatorTestCase#getUiDevice())()` **This function is deprecated.** Deprecated in Java |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `[sleep](https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiAutomatorTestCase#sleep(long))(ms: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)` **This function is deprecated.** Use `https://developer.android.com/reference/android/os/SystemClock.html#sleep(long)` instead. <br /> |

### Inherited functions

From [android.test.InstrumentationTestCase](https://developer.android.com/reference/android/test/InstrumentationTestCase.html) `https://developer.android.com/reference/android/app/Instrumentation.html!` `[getInstrumentation](https://developer.android.com/reference/android/test/InstrumentationTestCase.html#getInstrumentation())()`

**This function is deprecated.**
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `[injectInsrumentation](https://developer.android.com/reference/android/test/InstrumentationTestCase.html#injectInsrumentation(android.app.Instrumentation))(instrumentation: https://developer.android.com/reference/android/app/Instrumentation.html!)`

**This function is deprecated.**
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `[injectInstrumentation](https://developer.android.com/reference/android/test/InstrumentationTestCase.html#injectInstrumentation(android.app.Instrumentation))(instrumentation: https://developer.android.com/reference/android/app/Instrumentation.html!)`

**This function is deprecated.**
`T!` `<T : https://developer.android.com/reference/android/app/Activity.html?> [launchActivity](https://developer.android.com/reference/android/test/InstrumentationTestCase.html#launchActivity(java.lang.String, java.lang.Class&lt;T&gt;, android.os.Bundle))(
pkg: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!,
activityCls: https://developer.android.com/reference/java/lang/Class.html<T!>!,
extras: https://developer.android.com/reference/android/os/Bundle.html!
)`

**This function is deprecated.**
`T!` `<T : https://developer.android.com/reference/android/app/Activity.html?> [launchActivityWithIntent](https://developer.android.com/reference/android/test/InstrumentationTestCase.html#launchActivityWithIntent(java.lang.String, java.lang.Class&lt;T&gt;, android.content.Intent))(
pkg: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!,
activityCls: https://developer.android.com/reference/java/lang/Class.html<T!>!,
intent: https://developer.android.com/reference/android/content/Intent.html!
)`

**This function is deprecated.**
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `[runTest](https://developer.android.com/reference/android/test/InstrumentationTestCase.html#runTest())()`

**This function is deprecated.**
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `[runTestOnUiThread](https://developer.android.com/reference/android/test/InstrumentationTestCase.html#runTestOnUiThread(java.lang.Runnable))(r: https://developer.android.com/reference/java/lang/Runnable.html!)`

**This function is deprecated.**
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `[sendKeys](https://developer.android.com/reference/android/test/InstrumentationTestCase.html#sendKeys(int...))(keys: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html>!)`

**This function is deprecated.**
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `[sendRepeatedKeys](https://developer.android.com/reference/android/test/InstrumentationTestCase.html#sendRepeatedKeys(int...))(keys: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html>!)`

**This function is deprecated.**
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `[tearDown](https://developer.android.com/reference/android/test/InstrumentationTestCase.html#tearDown())()`

**This function is deprecated.**
From junit.framework.TestCase `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `assertEquals(message: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!, expected: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html!, actual: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html!)`

**This function is deprecated.** Deprecated in Java
`java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `assertFalse(message: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!, condition: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)`

**This function is deprecated.** Deprecated in Java
`java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `assertNotNull(object: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html!)`

**This function is deprecated.** Deprecated in Java
`java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `assertNotSame(message: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!, expected: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html!, actual: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html!)`

**This function is deprecated.** Deprecated in Java
`java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `assertNull(object: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html!)`

**This function is deprecated.** Deprecated in Java
`java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `assertSame(message: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!, expected: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html!, actual: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html!)`

**This function is deprecated.** Deprecated in Java
`java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `assertTrue(message: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!, condition: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)`

**This function is deprecated.** Deprecated in Java
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` `countTestCases()`

**This function is deprecated.** Deprecated in Java
`junit.framework.TestResult!` `createResult()`

**This function is deprecated.** Deprecated in Java
`java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `fail(message: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!)`

**This function is deprecated.** Deprecated in Java
`java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `failNotEquals(message: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!, expected: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html!, actual: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html!)`

**This function is deprecated.** Deprecated in Java
`java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `failNotSame(message: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!, expected: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html!, actual: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html!)`

**This function is deprecated.** Deprecated in Java
`java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `failSame(message: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!)`

**This function is deprecated.** Deprecated in Java
`java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` `format(message: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!, expected: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html!, actual: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html!)`

**This function is deprecated.** Deprecated in Java
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` `getName()`

**This function is deprecated.** Deprecated in Java
`junit.framework.TestResult!` `run()`

**This function is deprecated.** Deprecated in Java
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `run(result: junit.framework.TestResult!)`

**This function is deprecated.** Deprecated in Java
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `runBare()`

**This function is deprecated.** Deprecated in Java
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `setName(name: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!)`

**This function is deprecated.** Deprecated in Java
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `setUp()`

**This function is deprecated.** Deprecated in Java
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` `toString()`

**This function is deprecated.** Deprecated in Java

## Public constructors

### UiAutomatorTestCase

Added in 2.2.0 Deprecated in 2.2.0

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

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

## Public functions

### getAutomationSupport

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

```
fun [getAutomationSupport](https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiAutomatorTestCase#getAutomationSupport())(): IAutomationSupport!
```

> [!CAUTION]
> **This function is deprecated.**   
>
> Use `https://developer.android.com/reference/android/app/Instrumentation.html#sendStatus(int, android.os.Bundle)` instead

Provides support for running tests to report interim status

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/IAutomationSupport!` | IAutomationSupport |

### getParams

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

```
fun [getParams](https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiAutomatorTestCase#getParams())(): Bundle!
```

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

Get command line parameters. On the command line when passing `-e key value` pairs, the `https://developer.android.com/reference/android/os/Bundle.html` will have the key value pairs conveniently available to the tests.

### getUiDevice

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

```
fun [getUiDevice](https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiAutomatorTestCase#getUiDevice())(): UiDevice!
```

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

Get current instance of `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiDevice`. Works similar to calling the static `https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiDevice#getInstance()` from anywhere in the test classes.

### sleep

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

```
fun [sleep](https://developer.android.com/reference/kotlin/androidx/test/uiautomator/UiAutomatorTestCase#sleep(long))(ms: Long): Unit
```

> [!CAUTION]
> **This function is deprecated.**   
>
> Use `https://developer.android.com/reference/android/os/SystemClock.html#sleep(long)` instead.

Calls `https://developer.android.com/reference/android/os/SystemClock.html#sleep(long)` to sleep

| Parameters |
|---|---|
| `ms: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | is in milliseconds. |