XCTestCase:等待应用程序空闲

编程入门 行业动态 更新时间:2024-10-23 07:14:36
本文介绍了XCTestCase:等待应用程序空闲的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我的UI测试失败,因为测试等待无休止,直到应用程序空闲。我无法看到后台发生任何事情,比如加载微调器。

My UI-test fails because the test waits endless until the app idles. I can not see that there is anything happening in the background, like a loading spinner.

它只出现在一个选项卡上。所有其他选项卡都是可点击的,但测试在屏幕3上失败。在屏幕3上测试后,点击另一个选项卡,测试重新开始并成功完成。

It just occurs on one tab. All others tabs are tapable but the test fails on Screen 3. I I click on another tab after the test is caught on Screen 3 the test resumes and finishes successfully.

任何想法?

- (void)testExample { XCUIElementQuery* tabBarsQuery = self.app.tabBars; [tabBarsQuery.buttons[@"Screen2"] tap]; [tabBarsQuery.buttons[@"Screen3"] tap]; [tabBarsQuery.buttons[@"Screen1"] tap]; [tabBarsQuery.buttons[@"Screen4"] tap]; }

推荐答案

也许你有一些动画或一些其他背景(或前景)活动,经常在主线程上更新你的UI。这导致应用程序永远不会静默 - 至少在此选项卡上。在我们的应用程序中,我们有UIView动画,可选择Repeat。 CPU使用情况很好并且不是电池耗尽,但它每次都使测试失败。禁用动画修复了问题。我找不到一种方法来强制测试不要等待空闲,所以我们最终使用#ifdef禁用动画用于UI测试目标,使用运行时参数,如下所述: stackoverflow/a/33466038/168996

Perhaps you have some animation or some other background (or foreground) activity that updates your UI on the main thread frequently. This causes the app to never be "quiesce" - at least on this tab. In our application we had UIView animation with option Repeat. CPU usage was fine and it wasn't a battery drain, but it made the test fail every time. Disabling the animation fixed the issue. I couldn't find a way to force the test not to wait to be idle, so we ended up disabling the animation using #ifdef for the UI test target using runtime arguments as described here: stackoverflow/a/33466038/168996

更多推荐

XCTestCase:等待应用程序空闲

本文发布于:2023-11-11 10:36:39,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1578185.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:应用程序   XCTestCase

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!