Skip to content

Instantly share code, notes, and snippets.

@jabKnowsNothing
Last active February 15, 2017 15:20
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jabKnowsNothing/27006d96564386929248 to your computer and use it in GitHub Desktop.
Save jabKnowsNothing/27006d96564386929248 to your computer and use it in GitHub Desktop.
ActivityTestRule launchActivity=false
@RunWith(AndroidJUnit4.class)
public class MultipleIntentsTest {
@Rule
public ActivityTestRule<MyActivity> testRule = new ActivityTestRule<>(MyActivity.class,
false, // initialTouchMode
false); // launchActivity. False to set intent per test);
@Test
public void testOscarGrouchy() {
Intent grouchyIntent = new Intent();
// intent stuff
grouchyIntent.putExtra("EXTRA_IS_GROUCHY", true);
testRule.launchActivity(grouchyIntent);
// verify Oscar is grouchy
}
@Test
public void testOscarNotGrouchy() {
Intent happyIntent = new Intent();
// intent stuff
happyIntent.putExtra("EXTRA_IS_GROUCHY", false);
testRule.launchActivity(happyIntent);
// verify Oscar is not grouchy
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment