How to dynamically share data between MyAppUITests

2019-06-26 02:47发布

问题:

Within MyAppUITests I can pass some parameters to MyApp in following way:

app.launchEnvironment = ["my_param": "value"]
app.launch()

This is visible for MyApp and I can read this:

if let value = NSProcessInfo.processInfo().environment["my_param"] {
   //do sth with value
}

But this is how I can set it up BEFORE I launch the app. For some reason, I need to change "my_param" on runtime AFTER I launch the app. Any suggestions? I would appreciate any help.

Why do I need to do it for?

I need "my_param" to be able to change within MyAppUITests after I launch the app. "my_param" needs to be visible for MyApp in whatever place within MyApp. my_param might be mock response for my network client or whatever I need for that time.

NOTE:

Similar functionality is between App and its extension. There is solution with App Group and shared NSUserDefaults. What is here? Do I have to save it on device to share sth to another target?

UPDATE:

App Group doesn't work here.