AutoMate
AutoMate
是一个Swift框架,它包含了一组有用的XCTest
扩展,用于编写UI自动化测试。它提供了对启动参数和环境变量的强类型、可扩展封装,可用作设备的语言、区域设置和键盘类型配置。结合AutoMate-AppBuddy
,它可以禁用应用程序中的动画并管理事件、提醒和联系人。
安装
安装AutoMate有以下三种方便方式
-
使用CocoaPods(通过Podfile)
pod 'AutoMate'
-
使用Carthage并在
Cartfile.private
中添加一行github "PGSSoft/AutoMate"
Cartfile.private
应该被使用,因为AutoMate框架只用于UI测试目标,而不是测试的应用程序。 -
使用Swift包管理器,在Xcode中或
Package.swift
中.package(url: "https://github.com/PGSSoft/AutoMate", from: "1.8.0"),
使用方法
完整的文档可以在这里找到:https://pgssoft.github.io/AutoMate/。
-
创建一个新的UI测试用例类。
-
将
AutoMate
框架导入UI测试文件import AutoMate
-
在
setup()
方法中使用TestLauncher
配置应用程序设置并启动应用程序let app = XCUIApplication() TestLauncher(options: [ SystemLanguages([.English, .German]), SystemLocale(language: .English, country: .Canada), SoftwareKeyboards([.EnglishCanada, .GermanGermany]) ]).configure(app).launch()
-
在测试中使用AutoMate的扩展。例如
func testSomething() { let app = XCUIApplication() let button = app.button.element // helper for waiting until element is visible waitForVisibleElement(button, timeout: 20) button.tap() // isVisible - helper to check that element both exists and is hittable XCTAssertFalse(button.isVisible) }
功能(或待办事项)
- 设置键盘布局
- 设置区域
- 设置语言
- 自定义参数
- 自定义键盘布局、区域和语言
-
XCTest
扩展 - 添加了CoreData启动参数
- 禁用UIView动画(使用
AutoMate-AppBuddy
) - 强类型辅助器:定位器、页面对象模板(使用
AutoMate-Templates
) - 基类
Test.govX Testament
模板(使用AutoMate-Templates
) - 大多数权限提示(例如:
LocationWhenInUseAlert
、CalendarAlert
、PhotosAlert
),(使用AutoMate-ModelGenie
) - 管理事件、提醒和联系人(使用
AutoMate-AppBuddy
) - 为应用程序提供配套库(
AutoMate-AppBuddy
) - 改进启动选项类型安全性
- 智能坐标
- 检查应用程序是否在UI测试环境中运行(使用
AutoMate-AppBuddy
) - 模拟网络请求
- 模拟联系人、事件和提醒
- 获取屏幕截图
- 清除应用程序数据
- 模拟通知
示例应用程序
存储库包含在AutoMateExample
目录中的示例应用程序。应用程序结构简单,但该项目包含大量的UI测试套件,以展示库的功能。
开发
完整的文档可以在这里找到:https://pgssoft.github.io/AutoMate/。
如果您想提供自定义启动参数或启动环境,必须实现LaunchOption
协议或其扩展之一,例如LaunchArgumentWithSingleValue
enum CustomParameter: String, LaunchArgumentWithSingleValue, LaunchArgumentValue {
var key: String {
return "AppParameter"
}
case value1
case value2
}
然后,您可以将其传递给TestBuilder
let launcher = TestLauncher(options: [
CustomParameter.value1
])
贡献力量
Bug报告和Pull请求可以在GitHub上欢迎,地址:https://github.com/PGSSoft/AutoMate。
许可证
该项目可根据MIT许可协议
作为开源项目使用。
关于
该项目由软件开发机构PGS Software维护。查看我们的其他开源项目或联系我们以开发您的产品。