安卓& Robotium - waitForActivity 在它应该失败的时候不会失败?

发布于 2024-12-19 12:25:56 字数 174 浏览 2 评论 0原文

solo.clickOnButton("Login");
solo.waitForActivity("activityThatDoesntExist", 20000);

应用程序导航到名为“HomePageActivity”的活动,但即使活动名称不正确,测试也会通过?为什么会通过?

solo.clickOnButton("Login");
solo.waitForActivity("activityThatDoesntExist", 20000);

application navigates to an activity named "HomePageActivity", but the test passes even though the activity name is incorrect? Why does it pass?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

爱的那么颓废 2024-12-26 12:25:56

当超时时间内未找到 Activity 时,waitForActivity() 返回“false”。

waitForActivity() returns 'false' when the Activity isn't found within the timeout period.

最好是你 2024-12-26 12:25:56

为了确保在预期活动没有出现的情况下测试用例不会通过,我通常添加 assertTrue 方法。例如:

solo.clickOnButton("Login");
assertTrue(solo.waitForActivity("activityThatDoesntExist", 20000)); 

因此,当预期的活动不存在时,您可以捕获 AssertionFailedError 来使您的案例失败。

To make sure the test cases won't pass in case the expected activity doesn't show up, I usually add assertTrue method. like:

solo.clickOnButton("Login");
assertTrue(solo.waitForActivity("activityThatDoesntExist", 20000)); 

So when the expected activity doesn't exist, you can catch AssertionFailedError to fail your case.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文