[英]android espresso:test for new activity launch on button click is failing
I am testing whether a button click migrates to new activity using intended,and it is displaying the new activity being launched on device,but test case is failing,I am using the following code for same. 我正在测试按钮单击是否使用预期迁移到新活动,并且它正在显示正在设备上启动的新活动,但测试用例失败,我使用以下代码。
onView(withId(R.id.bt_click)).perform(click());
intended(hasComponent(hasClassName(CodeVerify.class.getName())));
I think you have to make it like this 我想你必须这样做
Intents.init();
onView(withId(R.id.bt_click)).perform(click());
intended(hasComponent(CodeVerify.class.getName()));
Intents.release();
if you provide more details it will be easier to help 如果您提供更多详细信息,将更容易提供帮助
您还可以使用IntentsTestRule
而不是ActivityTestRule
,它将在测试之前/之后自动调用init()和release()。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.