简体   繁体   English

Xcode本机UITest在真实设备上非常慢

[英]Xcode Native UITests very slow on real device

If I run my UITests on a simulator, they will run a lot faster, every interaction is faster somehow. 如果我在模拟器上运行UITest,它们的运行速度将大大提高,每次交互都会以某种方式更快。 Where a simulator takes about 20 seconds, a real device takes about 2 minutes. 模拟器大约需要20秒,而真实设备大约需要2分钟。

It's like I watch a sloth tap the buttons on the real device. 就像我看着树懒点击真实设备上的按钮一样。

Some info: 一些信息:

  • Xcode 9.2 Xcode 9.2
  • Devices: iPhone 6 plus (iOS 10.1.1) and iPad Air (10.3.3) 装置:iPhone 6 plus(iOS 10.1.1)和iPad Air(10.3.3)
  • MacBook Pro (Retina, 15-inch, Mid 2015) with MacOS Sierra 10.12.6 配备MacOS Sierra 10.12.6的MacBook Pro(Retina,15英寸,2015年中)
  • Swift 4 斯威夫特4
  • Simulator: iPhone 6 (iOS 11.2) 模拟器:iPhone 6(iOS 11.2)

I've noticed that an iPhone 6 plus running iOS 11.2.6 runs UITests significantly faster. 我注意到,运行iOS 11.2.6的iPhone 6 plus运行UITests的速度明显更快。 It is not a performance issue, it's an idling issue. 这不是性能问题,而是闲置问题。

Any ideas? 有任何想法吗?

There were 2 things I needed to do 我需要做两件事

Disable animations 禁用动画

禁用动画 .
This was the main thing, as the UITests were actually waiting for the app to idle (not in animating state) all the time. 这是最主要的事情,因为UITests实际上一直在等待应用程序空闲(不处于动画状态)。 With UITests I want to check if the UI flow is still intact, not if view transition animations still work, that is the job of iOS itself. 使用UITest,我想检查UI流程是否仍然完整,而不是查看过渡动画是否仍然有效,这是iOS本身的工作。

Switch to iOS 11+ 切换至iOS 11+
I noticed that iOS 11 was much faster than iOS 10. 我注意到iOS 11比iOS 10快得多。

After these changes the UITests were fast again :) 这些更改之后,UITests又很快了:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM