【发布时间】:2019-10-21 06:36:04
【问题描述】:
我有带有登录屏幕的应用程序和登录后出现的屏幕(授权部分)。
从授权部分测试这些屏幕的最佳方法是什么?
我有几个想法:
1) 不知何故,我需要在每次测试之前从钥匙串中删除所有数据,然后我每次都通过整个流程进入登录后的第一个屏幕。当我需要向后端发送登录请求时,我使用
等待主屏幕let nextGame = self.app.staticTexts["Main Screen Text"]
let exists = NSPredicate(format: "exists == true")
expectation(for: exists, evaluatedWithObject: nextGame, handler: nil)
waitForExpectations(timeout: 5, handler: nil)
2) 我在这里传递了一些参数
app = XCUIApplication(bundle:….)
app.launchArguments = [“notEmptyArguments”:”value”]
app.launch()
所以我可以传递一个假的token 并且后端将接受这个token,这样我的应用程序就会知道它必须将我路由到主屏幕并且所有请求都会成功,因为我的网络服务有这个假的token
但我认为这是一种不安全的方式。
你有什么想法什么是最好的方法,也许你可以提供更好的方法的建议?
【问题讨论】:
标签: ios xcode unit-testing xcode-ui-testing ios-ui-automation