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

# ProviderTestCase

*** ** * ** ***

` public abstract class ProviderTestCase `   
` ` ` extends https://developer.android.com/reference/android/test/InstrumentationTestCase ` ` `

|---|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) |||
| ↳ | [android.test.InstrumentationTestCase](https://developer.android.com/reference/android/test/InstrumentationTestCase) ||
|   | ↳ | android.test.ProviderTestCase\<T extends [android.content.ContentProvider](https://developer.android.com/reference/android/content/ContentProvider)\> |

<br />

*** ** * ** ***

<br />

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

this class extends InstrumentationTestCase but should extend AndroidTestCase. Use ProviderTestCase2, which corrects this problem, instead.

If you would like to test a single content provider with an `https://developer.android.com/reference/android/test/InstrumentationTestCase`, this provides some of the boiler plate in `https://developer.android.com/reference/android/test/ProviderTestCase#setUp()` and `https://developer.android.com/reference/android/test/ProviderTestCase#tearDown()`.

## Summary

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/android/test/ProviderTestCase#ProviderTestCase(java.lang.Class<T>,%20java.lang.String)(https://developer.android.com/reference/java/lang/Class<T> providerClass, https://developer.android.com/reference/java/lang/String providerAuthority) ` |

| ### Public methods ||
|---|---|
| ` https://developer.android.com/reference/android/test/mock/MockContentResolver` | ` https://developer.android.com/reference/android/test/ProviderTestCase#getMockContentResolver()() ` |
| ` https://developer.android.com/reference/android/test/IsolatedContext` | ` https://developer.android.com/reference/android/test/ProviderTestCase#getMockContext()() ` |
| ` T` | ` https://developer.android.com/reference/android/test/ProviderTestCase#getProvider()() ` |
| ` static <T extends https://developer.android.com/reference/android/content/ContentProvider> https://developer.android.com/reference/android/content/ContentResolver` | ` https://developer.android.com/reference/android/test/ProviderTestCase#newResolverWithContentProviderFromSql(android.content.Context,%20java.lang.Class<T>,%20java.lang.String,%20java.lang.String,%20int,%20java.lang.String)(https://developer.android.com/reference/android/content/Context targetContext, https://developer.android.com/reference/java/lang/Class<T> providerClass, https://developer.android.com/reference/java/lang/String authority, https://developer.android.com/reference/java/lang/String databaseName, int databaseVersion, https://developer.android.com/reference/java/lang/String sql) ` |

| ### Protected methods ||
|---|---|
| ` void` | ` https://developer.android.com/reference/android/test/ProviderTestCase#setUp()() ` |
| ` void` | ` https://developer.android.com/reference/android/test/ProviderTestCase#tearDown()() ` Tears down the environment for the test fixture. |

### Inherited methods

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

### ProviderTestCase

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

```
public ProviderTestCase (Class<T> providerClass, 
                String providerAuthority)
```

<br />

<br />

| Parameters ||
|---|---|
| `providerClass` | `Class` <br /> |
| `providerAuthority` | `String` <br /> |

## Public methods

### getMockContentResolver

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

```
public MockContentResolver getMockContentResolver ()
```

<br />

<br />

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

### getMockContext

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

```
public IsolatedContext getMockContext ()
```

<br />

<br />

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

### getProvider

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

```
public T getProvider ()
```

<br />

<br />

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

### newResolverWithContentProviderFromSql

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

```
public static ContentResolver newResolverWithContentProviderFromSql (Context targetContext, 
                Class<T> providerClass, 
                String authority, 
                String databaseName, 
                int databaseVersion, 
                String sql)
```

<br />

<br />

| Parameters ||
|---|---|
| `targetContext` | `Context` <br /> |
| `providerClass` | `Class` <br /> |
| `authority` | `String` <br /> |
| `databaseName` | `String` <br /> |
| `databaseVersion` | `int` <br /> |
| `sql` | `String` <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/content/ContentResolver` | <br /> |

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

## 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 ()
```

Tears down the environment for the test fixture.

Calls `https://developer.android.com/reference/android/content/ContentProvider#shutdown()` on the `https://developer.android.com/reference/android/content/ContentProvider` represented by mProvider.

<br />

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