我想使用UI测试框架(Espresso)为深度链接案例编写Android应用程序测试 - 仅使用ACTION_VIEW意图启动应用程序并检查打开屏幕上的所有视图.
但看起来像Espresso(甚至espresso-intents)没有这个功能,并且需要定义Activity类.
我试过这种方式,但它无法正常工作,因为启动了两次应用程序 - 使用AppLauncherActivity标准启动(Espresso需要)并通过深层链接启动.
@RunWith(AndroidJUnit4.class)
public class DeeplinkAppLauncherTest {
@Rule
public ActivityTestRule<AppLauncherActivity> activityRule = new ActivityTestRule<>(AppLauncherActivity.class);
@Test
public void testDeeplinkAfterScollDownAndBackUp() {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("myapp://search/777"));
activityRule.launchActivity(intent);
onView(withId(R.id.search_panel)).check(matches(isDisplayed()));
}
}
Run Code Online (Sandbox Code Playgroud)
我想在没有标准启动的情况下仅使用深层链接启动测试应用程序.你知道吗,怎么办?