In android I have a sample application with 2 Activities, MainActivity and DetailsActivity. In main activity, there is a list and a button, by pressing it the Details Activity is opened. In the intent, I put an ArrayList and an Object.
How can I Test that it works? Espresso Is it ok?
androidTestCompile 'com.android.support:support-annotations:25.3.1'
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2'
@RunWith(AndroidJUnit4.class)
@LargeTest
public class FirstTest {
@Rule
public IntentsTestRule<MainActivity> mActivityRule = new IntentsTestRule<>(
MainActivity.class);
@Test
public void changeText_sameActivity() {
onView(withId(R.id.fab)).perform(click());
// How can i Specify the intent to the new Detail Activity?
intended(hasComponent(new ComponentName(getTargetContext(), InsectDetailsActivity.class)));
onView(withId(R.id.tv_original_title))
.check(matches(withText( /* The text depends on the Passing Intent*/)));
}
}