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

# ActivityInstrumentationTestCase

*** ** * ** ***

` public abstract class ActivityInstrumentationTestCase `   
` ` ` ` ` extends https://developer.android.com/reference/android/test/ActivityTestCase ` ` `

|---|---|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||||
| ↳ | [android.test.InstrumentationTestCase](https://developer.android.com/reference/android/test/InstrumentationTestCase) |||
|   | ↳ | [android.test.ActivityTestCase](https://developer.android.com/reference/android/test/ActivityTestCase) ||
|   |   | ↳ | android.test.ActivityInstrumentationTestCase\<T extends [android.app.Activity](https://developer.android.com/reference/android/app/Activity)\> |

<br />

*** ** * ** ***

<br />

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

new tests should be written using `https://developer.android.com/reference/android/test/ActivityInstrumentationTestCase2`, which provides more options for configuring the Activity under test

This class provides functional testing of a single activity. The activity under test will be created using the system infrastructure (by calling InstrumentationTestCase.launchActivity()) and you will then be able to manipulate your Activity directly. Most of the work is handled automatically here by `https://developer.android.com/reference/android/test/ActivityInstrumentationTestCase#setUp()` and `https://developer.android.com/reference/android/test/ActivityInstrumentationTestCase#tearDown()`.

If you prefer an isolated unit test, see `https://developer.android.com/reference/android/test/ActivityUnitTestCase`.

## Summary

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/android/test/ActivityInstrumentationTestCase#ActivityInstrumentationTestCase(java.lang.String,%20java.lang.Class<T>)(https://developer.android.com/reference/java/lang/String pkg, https://developer.android.com/reference/java/lang/Class<T> activityClass) ` Creates an `https://developer.android.com/reference/android/test/ActivityInstrumentationTestCase` in non-touch mode. |
| ` https://developer.android.com/reference/android/test/ActivityInstrumentationTestCase#ActivityInstrumentationTestCase(java.lang.String,%20java.lang.Class<T>,%20boolean)(https://developer.android.com/reference/java/lang/String pkg, https://developer.android.com/reference/java/lang/Class<T> activityClass, boolean initialTouchMode) ` Creates an `https://developer.android.com/reference/android/test/ActivityInstrumentationTestCase`. |

| ### Public methods ||
|---|---|
| ` T` | ` https://developer.android.com/reference/android/test/ActivityInstrumentationTestCase#getActivity()() ` <br /> |
| ` void` | ` https://developer.android.com/reference/android/test/ActivityInstrumentationTestCase#testActivityTestCaseSetUpProperly()() ` |

| ### Protected methods ||
|---|---|
| ` void` | ` https://developer.android.com/reference/android/test/ActivityInstrumentationTestCase#setUp()() ` |
| ` void` | ` https://developer.android.com/reference/android/test/ActivityInstrumentationTestCase#tearDown()() ` Make sure all resources are cleaned up and garbage collected before moving on to the next test. |

### Inherited methods

From class ` https://developer.android.com/reference/android/test/ActivityTestCase ` ` https://developer.android.com/reference/android/app/Activity` ` https://developer.android.com/reference/android/test/ActivityTestCase#getActivity()() ` ` void` ` https://developer.android.com/reference/android/test/ActivityTestCase#scrubClass(java.lang.Class<?>)(https://developer.android.com/reference/java/lang/Class<?> testCaseClass) `

This function is called by various TestCase implementations, at tearDown() time, in order to scrub out any class variables.
` void` ` https://developer.android.com/reference/android/test/ActivityTestCase#setActivity(android.app.Activity)(https://developer.android.com/reference/android/app/Activity testActivity) `

Set the activity under test.
From class ` https://developer.android.com/reference/android/test/InstrumentationTestCase ` ` https://developer.android.com/reference/android/app/Instrumentation` ` https://developer.android.com/reference/android/test/InstrumentationTestCase#getInstrumentation()() `

Inheritors can access the instrumentation using this.
` void` ` https://developer.android.com/reference/android/test/InstrumentationTestCase#injectInsrumentation(android.app.Instrumentation)(https://developer.android.com/reference/android/app/Instrumentation instrumentation) `

*This method was deprecated in API level 15. Incorrect spelling, use `https://developer.android.com/reference/android/test/InstrumentationTestCase#injectInstrumentation(android.app.Instrumentation)` instead.*
` void` ` https://developer.android.com/reference/android/test/InstrumentationTestCase#injectInstrumentation(android.app.Instrumentation)(https://developer.android.com/reference/android/app/Instrumentation instrumentation) `

Injects instrumentation into this test case.
` final <T extends https://developer.android.com/reference/android/app/Activity> T` ` https://developer.android.com/reference/android/test/InstrumentationTestCase#launchActivity(java.lang.String,%20java.lang.Class<T>,%20android.os.Bundle)(https://developer.android.com/reference/java/lang/String pkg, https://developer.android.com/reference/java/lang/Class<T> activityCls, https://developer.android.com/reference/android/os/Bundle extras) `

Utility method for launching an activity.
` final <T extends https://developer.android.com/reference/android/app/Activity> T` ` https://developer.android.com/reference/android/test/InstrumentationTestCase#launchActivityWithIntent(java.lang.String,%20java.lang.Class<T>,%20android.content.Intent)(https://developer.android.com/reference/java/lang/String pkg, https://developer.android.com/reference/java/lang/Class<T> activityCls, https://developer.android.com/reference/android/content/Intent intent) `

Utility method for launching an activity with a specific Intent.
` void` ` https://developer.android.com/reference/android/test/InstrumentationTestCase#runTest()() `

Runs the current unit test.
` void` ` https://developer.android.com/reference/android/test/InstrumentationTestCase#runTestOnUiThread(java.lang.Runnable)(https://developer.android.com/reference/java/lang/Runnable r) `

Helper for running portions of a test on the UI thread.
` void` ` https://developer.android.com/reference/android/test/InstrumentationTestCase#sendKeys(int[])(int... keys) `

Sends a series of key events through instrumentation and waits for idle.
` void` ` https://developer.android.com/reference/android/test/InstrumentationTestCase#sendKeys(java.lang.String)(https://developer.android.com/reference/java/lang/String keysSequence) `

Sends a series of key events through instrumentation and waits for idle.
` void` ` https://developer.android.com/reference/android/test/InstrumentationTestCase#sendRepeatedKeys(int[])(int... keys) `

Sends a series of key events through instrumentation and waits for idle.
` void` ` https://developer.android.com/reference/android/test/InstrumentationTestCase#tearDown()() `

Make sure all resources are cleaned up and garbage collected before moving on to the next test.
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*.

## Public constructors

### ActivityInstrumentationTestCase

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

```
public ActivityInstrumentationTestCase (String pkg, 
                Class<T> activityClass)
```

Creates an `https://developer.android.com/reference/android/test/ActivityInstrumentationTestCase` in non-touch mode.

<br />

| Parameters ||
|---|---|
| `pkg` | `String`: ignored - no longer in use. <br /> |
| `activityClass` | `Class`: The activity to test. This must be a class in the instrumentation targetPackage specified in the AndroidManifest.xml <br /> |

### ActivityInstrumentationTestCase

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

```
public ActivityInstrumentationTestCase (String pkg, 
                Class<T> activityClass, 
                boolean initialTouchMode)
```

Creates an `https://developer.android.com/reference/android/test/ActivityInstrumentationTestCase`.

<br />

| Parameters ||
|---|---|
| `pkg` | `String`: ignored - no longer in use. <br /> |
| `activityClass` | `Class`: The activity to test. This must be a class in the instrumentation targetPackage specified in the AndroidManifest.xml <br /> |
| `initialTouchMode` | `boolean`: true = in touch mode <br /> |

## Public methods

### getActivity

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

```
public T getActivity ()
```

<br />

<br />

| Returns ||
|---|---|
| `T` | Returns the activity under test. <br /> |

### testActivityTestCaseSetUpProperly

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

```
public void testActivityTestCaseSetUpProperly ()
```

<br />

<br />

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/Exception` |   |

## Protected methods

### setUp

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

```
protected void setUp ()
```

<br />

<br />

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/Exception` |   |

### tearDown

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

```
protected void tearDown ()
```

Make sure all resources are cleaned up and garbage collected before moving on to the next test. Subclasses that override this method should make sure they call super.tearDown() at the end of the overriding method.

<br />

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/Exception` |   |