ios - Xcode UI 测试用例,在 UINavigationController 中有许多控制器的 XCtestcase
问题描述
为第一个屏幕编写 UI 测试用例似乎很简单。
如下所示。
func testExample() {
let app = XCUIApplication()
let textField = app.otherElements.containing(.navigationBar, identifier:"id").children(matching: .other).element.children(matching: .other).element.children(matching: .other).element.children(matching: .textField).element
textField.tap()
textField.tap()
app.navigationBars["id"].buttons["Done"].tap()
}
但是如何编写一个测试用例,其中一个导航控制器触发另一个屏幕,如下所示。
导航控制器 -> UIViewController1 -> UIViewcontroller2 .....UIViewController5
为了测试 UIViewController5,我将不得不编写大量代码,其中包括以下逻辑
1)启动应用程序。
2) 启动 Controller1 ,执行事件到 Launch Controller2
3)重复步骤2,直到到达Controller5。
我相信 UI 测试用例应该很简单,不应该花时间。
在这种情况下,理想的方法应该是什么,因为要运行 Controller5 的测试用例,它必须执行它之前的所有事件?
解决方案
推荐阅读
- java - Java中有没有办法直接在charArray中输入?
- c# - ASP.NET CORE DI - 从 EF Core 的 Database.GetDbConnection() 中解析 IDbConnection
- wildfly - 使用启动脚本通过 CLI 将 Zipkin 跟踪添加到 WildFly
- php - 从 MySQL 表中删除一行
- hyperledger-fabric - 链码 bor 已在通道 mychannel 上成功定义并重试:'bor' 的链码定义存在,但未安装链码
- javascript - 对象数组中的日期比较和过滤数据
- postgresql - SELECT DISTINCT ON 之类的东西,但对于 N > 1
- android - 显示未找到结果
- c++ - 如何访问安装在 docker 容器上的第三方 C++ 库?
- c# - 通过依赖属性 (UWP) 更改 VisualState