Summary: Ctors | Protected Methods | Inherited Methods | [Expand All]

# IntentsTestRule

`public class IntentsTestRule`
`` `` `extends ActivityTestRule<T extends Activity>` ``

java.lang.Object
↳ | android.support.test.rule.UiThreadTestRule
| ↳ | android.support.test.rule.ActivityTestRule<T extends android.app.Activity>
|  | ↳ | android.support.test.espresso.intent.rule.IntentsTestRule<T extends android.app.Activity>

This rule makes it easy to use Espresso-Intents APIs in functional UI tests. This class is an extension of `ActivityTestRule`, which initializes Espresso-Intents before each test annotated with `Test` and releases Espresso-Intents after each test run. The Activity will be terminated after each test and this rule can be used in the same way as `ActivityTestRule`.

Espresso-Intents APIs can be used in two ways:

- Intent Verification, using the `intended(Matcher)` API
- Intent Stubbing, using the `intending(Matcher)` API

## Summary

### Public constructors
`IntentsTestRule(Class<T> activityClass)`
`IntentsTestRule(Class<T> activityClass, boolean initialTouchMode)`
`IntentsTestRule(Class<T> activityClass, boolean initialTouchMode, boolean launchActivity)`

### Protected methods
`void` | `afterActivityFinished()` Override this method to execute any code that should run after your `Activity` is finished.
`void` | `afterActivityLaunched()` Override this method to execute any code that should run after your `Activity` is launched, but before any test code is run including any method annotated with `Before`.

### Inherited methods
From class `android.support.test.rule.ActivityTestRule`
`void` | `afterActivityFinished()` Override this method to execute any code that should run after your `Activity` is finished.
`void` | `afterActivityLaunched()` Override this method to execute any code that should run after your `Activity` is launched, but before any test code is run including any method annotated with `Before`.
`Statement` | `apply(Statement base, Description description)`
`void` | `beforeActivityLaunched()` Override this method to execute any code that should run before your `Activity` is created and launched.
`T` | `getActivity()`
`Intent` | `getActivityIntent()` Override this method to set up Intent as if supplied to `startActivity(Intent)`.
`T` | `launchActivity(Intent startIntent)` Launches the Activity under test.
From class `android.support.test.rule.UiThreadTestRule`
`Statement` | `apply(Statement base, Description description)`
`void` | `runOnUiThread(Runnable runnable)` Helper for running portions of a test on the UI thread.
`boolean` | `shouldRunOnUiThread(Description description)`
From class `java.lang.Object`
`Object` | `clone()`
`boolean` | `equals(Object arg0)`
`void` | `finalize()`
`final Class<?>` | `getClass()`
`int` | `hashCode()`
`final void` | `notify()`
`final void` | `notifyAll()`
`String` | `toString()`
`final void` | `wait(long arg0, int arg1)`
`final void` | `wait(long arg0)`
`final void` | `wait()`
From interface `org.junit.rules.TestRule`
`abstract Statement` | `apply(Statement arg0, Description arg1)`

## Public constructors

### IntentsTestRule

    IntentsTestRule (Class<T> activityClass)

Parameters
`activityClass` | `Class`

### IntentsTestRule

    IntentsTestRule (Class<T> activityClass,
                    boolean initialTouchMode)

Parameters
`activityClass` | `Class`
`initialTouchMode` | `boolean`

### IntentsTestRule

    IntentsTestRule (Class<T> activityClass,
                    boolean initialTouchMode,
                    boolean launchActivity)

Parameters
`activityClass` | `Class`
`initialTouchMode` | `boolean`
`launchActivity` | `boolean`

## Protected methods

### afterActivityFinished

    void afterActivityFinished ()

Override this method to execute any code that should run after your `Activity` is finished. This method is called after each test method, including any method annotated with `After`.

### afterActivityLaunched

    void afterActivityLaunched ()

Override this method to execute any code that should run after your `Activity` is launched, but before any test code is run including any method annotated with `Before`.

Prefer `Before` over this method. This method should usually not be overwritten directly in tests and only be used by subclasses of ActivityTestRule to get notified when the activity is created and visible but test runs.

- ## Classes

  - IntentsTestRule