使用浓缩咖啡测试多种活动 [英] Testing multiple activities with espresso
本文介绍了使用浓缩咖啡测试多种活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以使用android espresso框架跨多个活动编写测试?
Is it possible to write tests across several activities using the android espresso framework?
推荐答案
Yes, it is possible. In one of the samples they have demoed this here https://github.com/googlesamples/android-testing/blob/master/ui/espresso/BasicSample/app/src/androidTest/java/com/example/android/testing/espresso/BasicSample/ChangeTextBehaviorTest.java
@Test
public void changeText_newActivity() {
// Type text and then press the button.
onView(withId(R.id.editTextUserInput)).perform(typeText(STRING_TO_BE_TYPED),
closeSoftKeyboard());
onView(withId(R.id.activityChangeTextBtn)).perform(click());
// This view is in a different Activity, no need to tell Espresso.
onView(withId(R.id.show_text_view)).check(matches(withText(STRING_TO_BE_TYPED)));
}
阅读嵌入式注释.
Espresso暗中负责等待加载新活动.
Waiting for the new activity to load is taken care of implicitly by Espresso.
这篇关于使用浓缩咖啡测试多种活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文