如果我有MainActivity和DetailActivity,我该如何测试DetailActivity是否已经启动?
public class MainScreenTest {
@Rule
public IntentsTestRule<MainActivity> mainActivityRule =
new IntentsTestRule<>(MainActivity.class);
@Test
public void shouldOpenDetailActivityOnClick() {
onView(withId(R.id.button)).check(matches(withText("Detail")));
onView(withId(R.id.button))
.perform(click());
...
}
}
答案 0 :(得分:0)
这是一种方法:
public class MainScreenTest {
@Rule
public IntentsTestRule<MainActivity> mainActivityRule =
new IntentsTestRule<>(MainActivity.class);
@Test
public void shouldOpenDetailActivityOnClick() {
onView(withId(R.id.button)).check(matches(withText("Detail")));
onView(withId(R.id.button))
.perform(click());
intended(hasComponent("com.example.androidplayground.DetailActivity"));
}
}