【发布时间】:2017-03-22 12:08:00
【问题描述】:
我想使用 UI 测试框架 (Espresso) 为 Android app with deep link cases 编写测试 - 仅使用 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()));
}
}
我想仅使用深层链接而不使用标准启动来启动测试应用。 你知道怎么做吗?
【问题讨论】:
-
我已经在这里stackoverflow.com/questions/44074173/…回复了同样的问题。希望对您有所帮助!
标签: android deep-linking android-testing android-espresso