0

I'm doing some UI testing in my iOS app but I'm seeing some strange behaviour.

In my setUp() method I'm adding some values to XCUIApplication().launchArguments but when I query to see the launch arguments, I'm getting and empty array.

This is how my setUp() method looks like:

override func setUp() {
    super.setUp()

    let application = XCUIApplication()
    application.launchArguments = ["USE_SERVER_DEBUG"]
    application.launch()
}

This is the function that calls Process.arguments to retrieve the arguments

func checkArguments(){
    let launchArguments = Process.arguments
    for index in 0 ..< launchArguments.count {
        let argument = launchArguments[index] as String

        if argument.compare("USE_DEBUG_SERVER") == NSComparisonResult.OrderedSame {
            // Do something
        }
    }
    return true
}
rmaddy
  • 314,917
  • 42
  • 532
  • 579
breaktop
  • 1,899
  • 4
  • 37
  • 58
  • I don't know anything about Automation, but check this answer out. It appears that you may not be accessing the proper process. http://stackoverflow.com/a/33335994/1671729 – Putz1103 May 25 '16 at 20:07

1 Answers1

0

I'm not sure if Process is your own class or a typo, but you should be using NSProcessInfo.

if NSProcessInfo.processInfo().arguments.contains("USE_SERVER_DEBUG") {
    // Do something
}

Also, I usually recommend against setting the launch arguments. Instead, you should append to them. But that's more of a best practice than anything.

application.launchArguments += "USE_SERVER_DEBUG"
Joe Masilotti
  • 16,815
  • 6
  • 77
  • 87