Tips & Tricks gleaned for XCUIApplication Launch Arguments

Aya Akl
3 min readMay 10, 2020

--

The app under test or the test app target that we are using to write UI Tests against has some important properties which is called Launch Arguments & Environments. My main focus is on the Arguments. Based on Apple definition: They are the arguments that will be passed to the application on launch.

Some points to take into consideration:

  1. They are used when launch the application, so if you want to send something in the current test run, you should give it before launching the App.
  2. If launch arguments are given to the app in a test run that is already running, changes will only be applied in the next test run

How to set them:

How to use them in Testing:

Play around them:

Because we want our testing experience to be flexible and generic, we can play around these launch arguments for better experience as follows. Why not to store these strings in one place and then call them without the need to rewrite the strings many times that sometimes could go wrong because we are humans and we can do mistakes 😉

So we will use enums and extensions once more as follows:

1- Create and enum with launch arguments string values (only once)

2- Extend the ProcessInfo like for better usage of launch arguments + with the LaunchArgument Usage

3- Use the ProcessInfo extension

Play around LaunchArguments & XCUIApplication:

If we want to more generalisation to our tests, we can add launch app method of our own by following the below steps

1- Add default launch arguments:

2- Launch the app with any extra launch arguments based on each test case:

HAPPY TESTING!

Originally published at http://ayaakl.wordpress.com on May 10, 2020.

--

--

Aya Akl

#Quality is my thing - Passionate human being who wants to change the world!! #MobileTester #SDET #iOS #Testing