| java.lang.Object | ||
| ↳ | org.junit.rules.ExternalResource | |
| ↳ | androidx.test.ext.junit.rules.ActivityScenarioRule<A extends android.app.Activity> | |
ActivityScenarioRule launches a given activity before the test starts and closes after the test.
You can access to scenario interface via getScenario() method. You may finish your
activity manually in your test, it will not cause any problems and this rule does nothing after
the test in such cases.
This rule is an upgraded version of ERROR(/androidx.test.rule.ActivityTestRule). The previous
version will be deprecated and eventually be removed from the library in the future.
Example:
@Rule public ActivityScenarioRulerule = new ActivityScenarioRule<>(MyActivity.class); @Test public void myTest() { ActivityScenario scenario = rule.getScenario(); // Your test code goes here. }
| Public Constructors | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
Constructs ActivityScenarioRule for a given activity class.
| |||||||||||
Constructs ActivityScenarioRule with a given intent.
| |||||||||||
| Public Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
Returns
ActivityScenario of the given activity class. | |||||||||||
| Protected Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
|
[Expand]
Inherited Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
|
| |||||||||||
|
| |||||||||||
|
| |||||||||||
Constructs ActivityScenarioRule for a given activity class.
| Parameters | |
|---|---|
activityClass |
Class: an activity class to launch
|
| Parameters | |
|---|---|
activityClass |
Class |
activityOptions |
Bundle: an activity options bundle to be passed along with the intent to start
activity.
|
See also:
Constructs ActivityScenarioRule with a given intent.
| Parameters | |
|---|---|
startActivityIntent |
Intent: an intent to start an activity
|
| Parameters | |
|---|---|
startActivityIntent |
Intent |
activityOptions |
Bundle: an activity options bundle to be passed along with the intent to start
activity.
|
See also:
Returns ActivityScenario of the given activity class.
| Returns | |
|---|---|
ActivityScenario<A> |
a non-null ActivityScenario instance
|
| Throws | |
|---|---|
NullPointerException |
if you call this method while test is not running |