[英]Android Espresso: How to test whether a button click migrates to a new screen?
onView(withId(R.id.BUTTON))
.perform(click())
.check(matches(withContentDescription(R.id.my_layout)));
onView(withId(R.id.tp_layout))
.check(matches(isDisplayed()));
I am trying to test whether button click migrates to next screen or not.. how can I match, with this only first test is running and it displays tests failed. 我试图测试按钮单击是否迁移到下一个屏幕..如何匹配,只有第一个测试正在运行,它显示测试失败。
You can use Espresso extension - Espresso-Intents. 您可以使用Espresso扩展 - Espresso-Intents。
Here is the official tutorial . 这是官方教程 。
Short quote: 简短的报价:
Espresso-Intents records all intents that attempt to launch activities from the application under test. Espresso-Intents记录尝试从被测应用程序启动活动的所有意图。 Using the intended API (cousin of Mockito.verify), you can assert that a given intent has been seen. 使用预期的API(Mockito.verify的表兄弟),您可以断言已经看到给定的意图。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.