Set extras for testing activity. For every single tests - different extrax.
@SmallTest
@RunWith(AndroidJUnit4.class)
public class MainActivityTest {
@Rule
public ActivityTestRule<MainActivity> mActivityRule =
new ActivityTestRule<>(MainActivity.class, true, false);
@Test
public void someTest() {
Context targetContext = InstrumentationRegistry.getInstrumentation()
.getTargetContext();
Intent intent = new Intent(targetContext, MainActivity.class);
intent.putExtra("Name", "Value");
mActivityRule.launchActivity(intent);
/* Your activity is initialized and ready to go. */
}
}