【发布时间】:2019-01-15 03:37:44
【问题描述】:
我正在为 healthkit 编写一个 react-native 桥,其中包括 Healthkit 的初始化。我还需要为模块编写单元测试。
我想使用 Travis 对项目进行自动测试。因此,我需要一种可以按下Allow 按钮的自动方式。否则权限UI会阻塞单元测试过程。
所以,我需要知道如何自动按下允许按钮。
【问题讨论】:
标签: ios objective-c react-native travis-ci
我正在为 healthkit 编写一个 react-native 桥,其中包括 Healthkit 的初始化。我还需要为模块编写单元测试。
我想使用 Travis 对项目进行自动测试。因此,我需要一种可以按下Allow 按钮的自动方式。否则权限UI会阻塞单元测试过程。
所以,我需要知道如何自动按下允许按钮。
【问题讨论】:
标签: ios objective-c react-native travis-ci
我在我的 XCTests 中使用 this 库,我没有专门测试 HealthKit 警报,但它似乎受支持。
https://github.com/PGSSoft/AutoMate/blob/master/AutoMate/Models/HealthAlerts.swift
【讨论】:
我可以通过以下方式访问这些按钮:
lazy var turnOnAllCategories = app.tables.cells.firstMatch
lazy var allowCategoriesConnectionButton = app.navigationBars.buttons.element(boundBy: 1)
在我的测试中,我检查弹出表单是否显示:
if turnOnAllCategories.waitForExistence(timeout: waitForExistenceTimeFrame) {
turnOnAllCategories.tap()
allowCategoriesConnectionButton.tap()
}
请记住,根据您的 UI,您可能需要更多地过滤 app.tables 和 app.navigationBars.buttons
的结果>【讨论】: