class IntentsTestRule<T : Activity?> : ActivityTestRule


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 org.junit.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 .

Espresso-Intents APIs can be used in two ways:

  • Intent Verification, using the intended API
  • Intent Stubbing, using the intending API
Parameters
<T : Activity?>

The activity to test

Summary

Public constructors

IntentsTestRule(activityClass: Class<T!>!)
IntentsTestRule(activityClass: Class<T!>!, initialTouchMode: Boolean)
IntentsTestRule(
    activityClass: Class<T!>!,
    initialTouchMode: Boolean,
    launchActivity: Boolean
)

Protected functions

Unit

Override this method to execute any code that should run after the currently launched is finished.

Unit

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 .

Inherited functions

From androidx.test.rule.ActivityTestRule
Statement!
apply(base: Statement!, description: Description!)
Unit

Override this method to execute any code that should run before your Activity is created and launched.

Unit

Finishes the currently launched Activity.

T!

Returns the reference to the activity under test.

Intent!

Override this method to set up a custom Intent as if supplied to startActivity.

T!
launchActivity(startIntent: Intent?)

Launches the Activity under test.

Unit
runOnUiThread(runnable: Runnable!)

Helper method for running part of a method on the UI thread, blocking until it is complete.

From org.junit.rules.TestRule
abstract Statement!

Public constructors

IntentsTestRule

IntentsTestRule(activityClass: Class<T!>!)

IntentsTestRule

IntentsTestRule(activityClass: Class<T!>!, initialTouchMode: Boolean)

IntentsTestRule

IntentsTestRule(
    activityClass: Class<T!>!,
    initialTouchMode: Boolean,
    launchActivity: Boolean
)

Protected functions

afterActivityFinished

protected fun afterActivityFinished(): Unit

Override this method to execute any code that should run after the currently launched is finished. This method is called after each test method, including any method annotated with org.junit.After.

Prefer org.junit.After 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.

afterActivityLaunched

protected fun afterActivityLaunched(): Unit

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 .

Prefer org.junit.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.