0

Problem Statement:

My Test flow will depend on the type of configuration that is currently running for a test plan. I want to get the configuration name and environment variable entries of the currently running test plan in Xcode, so that according to the configuration I can decide what action to perform in a particular test.

Eg.

I have a test plan XYZ.xctestplan with two configurations "A" and "B". I want to get the environment variable entries that are set in the currently running configuration of the XYZ.xctestplan According to these environment variables, I will decide which button should be clicked in my UI test.

Samarth Kejriwal
  • 1,168
  • 2
  • 15
  • 30

1 Answers1

1

You can pull the environment variables in, say named "359TZ", like this:

    NSString *key = @"359TZ";
    NSString *tz359 = [NSProcessInfo.processInfo.environment objectForKey:key];

Please note that IIRC, you get the environment variables in a configuration when you run from Xcode, but not when you run using xcodebuild. YMMV.

Steve Mykytyn
  • 73
  • 2
  • 7
  • What do you mean by the above "NOTE" statement. Please clarify it more. means if I run my test plan using xcodebuild, then I won't be able to get the environment variables? – Samarth Kejriwal Feb 27 '21 at 14:53
  • As of this morning, it looks like it does obtain environment variables with xcodebuild, but it does not respect any custom location provided by a .gpx file. I'll have to look a little more into this. – Steve Mykytyn Feb 28 '21 at 16:06
  • https://github.com/fastlane/fastlane/issues/1678 Apparently a long standing issue – Steve Mykytyn Feb 28 '21 at 16:21
  • In my case, I am only dealing with the env. variables. so I think it should work for me. – Samarth Kejriwal Mar 01 '21 at 05:05