Ole*_*aev 5 multithreading android android-espresso
我刚开始使用 Espresso,在此之前我尝试过 Robotium。我需要测试 LoginActivity。逻辑是:
测试登录源:
public void testLogin() throws Exception{
onView(withId(R.id.login_email)).perform(typeText(LOGIN_EMAIL));
onView(withId(R.id.login_password)).perform(typeText(LOGIN_PASSWORD));
onView(withId(R.id.login_loginBtn)).perform(click());
onView(withText(R.string.loading_logging_in)).check(matches(isDisplayed()));
onView(withText("You're logged in")).check(matches(isDisplayed()));
}
Run Code Online (Sandbox Code Playgroud)
问题是浓缩咖啡没有等待“您已登录”字符串出现,而是在登录过程中尝试找到它。
日志猫:
com.google.android.apps.common.testing.ui.espresso.NoMatchingViewException:在层次结构中没有找到匹配的视图:文本:是“您已登录”
我试过使用 Thread.sleep(10000),但它终止了 Thread.sleep(10000) 上的运行并给我错误:
测试未能运行完成。原因:“由于“进程崩溃”,检测运行失败。”。检查设备日志以获取详细信息 测试运行失败:由于“进程崩溃”,仪器运行失败。
日志猫:
@@@ @@@ @@@ 被 HttpReRegistrationService 中的 cancelService 杀死
在此之前,我使用了 waitForActivity(MainActivity.class) 方法。是否有任何解决方法可以使这项工作?