简体   繁体   English

如何从XCUItest类中设置可在应用程序委托中访问的参数

[英]How to set arguments from XCUItest class that are accessible in app delegate

I would like to set a variable or dictionary in my XCUITest that will decide which screen to show when the app starts. 我想在XCUITest中设置一个变量或字典,该变量或字典将决定应用程序启动时显示哪个屏幕。 The variable or dictionary should be accessible in the app delegate is this possible. 可以在应用程序委托中访问变量或字典。

Just at the top of my mind I am thinking of something along the lines of , NSDefaults, launchArguments or environment variables. 只是在我的脑海中,我正在思考一些类似于NSDefaults,launchArguments或环境变量的东西。 Is it possible to set a variable in XCUItest and access it in the App delegate before the app starts so that the variable can be used to determine which screen to show. 是否可以在XCUItest中设置变量并在应用启动之前在应用委托中访问它,以便可以使用该变量确定显示哪个屏幕。

You can use launchArguments in your UI test. 您可以在UI测试中使用launchArguments I would use it like that: 我会这样使用它:

app.launchArguments.append("setupForAbcUITest")

and then, you can use it in AppDelegate didFinishLaunchingWithOptions 然后,您可以在AppDelegate didFinishLaunchingWithOptions使用它

if ProcessInfo.processInfo.arguments.contains("setupForAbcUITest") {
    /// create dictionary or anything you like
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM