【发布时间】:2016-01-04 10:47:17
【问题描述】:
我尝试在 XCUIApplication 实例中设置属性,在我的 UI 测试 setUp() 中
let app = XCUIApplication()
app.launchEnvironment = ["testenv" : "testenvValue"]
app.launchArguments = ["anArgument"]
app.launch()
在didFinishLaunch 中,我尝试在运行 UITests 时将这些显示在屏幕上
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
if launchOptions != nil {
for (key, value) in launchOptions! {
let alertView = UIAlertView(title: key.description, message: value.description, delegate: nil, cancelButtonTitle: "ok")
alertView.show()
}
}
但我似乎无法找到我设置的参数和环境。有谁知道如何获取它们?
【问题讨论】:
-
是的,我也找不到它们——希望有更多关于这些东西的文档。很酷只是......很难进行一些好的测试。
-
嗨,你有没有机会知道苹果网站上是否有任何使用
launchArguments的例子?官方文档简直要了我的命:The arguments that will be passed to the application on launch(developer.apple.com/documentation/xctest/xcuiapplication/…)。好像从名字上看不出来
标签: ios xcode swift ui-testing