如何在XCODE 8,Swift 3中使用UIAutomation

时间:2017-03-20 09:55:28

标签: swift unit-testing xcode8 ui-automation

导入XCTest

class 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 个答案:

答案 0 :(得分:1)

我相信UIAutomation在Xcode 8中已被弃用。但您只需执行以下操作即可在Xcode 8中设置UI测试:

  1. 将iOS UI测试包目标添加到您的项目中。
  2. 在作为该目标的一部分创建的新测试文件下创建测试方法。
  3. 在方法中的花括号内单击。
  4. 点击"记录"源编辑器下方显示的图标,用于开始在模拟器中记录您的UI操作。
  5. 观看此WWDC Video以了解有关Xcode中的UI测试的更多信息。