如何在Xcode中加速UI测试用例? [英] How to speed up UI test cases in Xcode?

查看:132
本文介绍了如何在Xcode中加速UI测试用例?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Xcode 7 以来,我们有一个很好的用于UI测试的API。
我对它很满意。唯一的问题与速度有关。

Since Xcode 7 we have a nice API for UI testing. Mostly I'm satisfied with it. The only concern is related to the speed.

一开始普通的UI测试用例(大约15个动作)大约 25秒。然后我完全嘲笑网络。现在需要 20秒。考虑到时间只取决于动画和启动时间(1秒甚至更短),我认为,必须有办法加快速度。

In the beginning an ordinary UI test case (about 15 actions) ran approximately 25 seconds. Then I mocked networking completely. Now it takes 20 seconds. Considering the fact that the time is taken only by animations and a launch time (1 second or even less), I assume, there must be a way to speed it up.

推荐答案

尝试在UI测试运行时设置此属性:

Try setting this property when your UI tests run:

UIApplication.shared.keyWindow?.layer.speed = 100

以下是我设置的方式:

func application(_ application: UIApplication,
                 didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {

    if ProcessInfo.processInfo.arguments.contains("UITests") {
        UIApplication.shared.keyWindow?.layer.speed = 100
    }
}

在我的UI测试中:

class MyAppUITests: XCTestCase {

    // MARK: - SetUp / TearDown

    override func setUp() {
        super.setUp()

        let app = XCUIApplication()
        app.launchArguments = ["UITests"]
        app.launch()
    }
}

这里有一些方便的提示博客文章

There's a few more handy tips in this blog post.

这篇关于如何在Xcode中加速UI测试用例?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆