我如何在 XCODE 8、Swift 3 中使用 UIAutomation

Posted

技术标签:

【中文标题】我如何在 XCODE 8、Swift 3 中使用 UIAutomation【英文标题】:How can i use UIAutomation in XCODE 8 , Swift 3 【发布时间】:2017-03-20 09:55:27 【问题描述】:

导入 XCTest

类 UnitTestClass: XCTestCase

override func setUp() 
    super.setUp()
    // Put setup code here. This method is called before the invocation of each test method in the class.


override func tearDown() 
    // Put teardown code here. This method is called after the invocation of each test method in the class.
    super.tearDown()


func testExample() 


我的应用中有多个 UIViewController 类。现在,我想在 Xcode 8、swift 3 中通过 UIAutomation 测试每个类。经过大量搜索,我在 Xcode 或 swift 的最新版本中没有得到任何有用的教程或工具。我的应用程序的第一个屏幕是登录屏幕。谁能帮我找出有用的解决方案

【问题讨论】:

【参考方案1】:

我相信 UIAutomation 在 Xcode 8 中已被弃用。但您可以通过简单地执行以下操作在 Xcode 8 中设置 UI 测试:

    ios UI 测试包目标添加到您的项目中。 在作为该目标的一部分创建的新测试文件下创建一个测试方法。 在方法内的花括号内单击。 点击源编辑器下方显示的“记录”图标,开始在模拟器中记录您的 UI 操作。

观看此WWDC Video,了解有关 Xcode 中的 UI 测试的更多信息。

【讨论】:

以上是关于我如何在 XCODE 8、Swift 3 中使用 UIAutomation的主要内容,如果未能解决你的问题,请参考以下文章