XCTest无法读取启动参数

问题描述 投票:1回答:1

我正在运行UI测试,并在setUp()方法中设置了启动参数:

self.app = XCUIApplication()
self.app.launch()        
self.app.launchArguments.append("UITesting")

然后稍后在测试中,我尝试通过这种方式读取启动参数:

if ProcessInfo.processInfo.arguments.contains("UITesting") {
    // do something
}

但是if内的代码永远不会执行。如何运作?

ios swift xctest ui-testing
1个回答
2
投票

您无法在启动应用后设置启动参数。

您应设置启动环境变量,然后启动应用程序

    app.launchArguments.append("UITesting")
    app.launch() 
© www.soinside.com 2019 - 2024. All rights reserved.