I have the following code in my application. Its behavior can be changed by setting the "MY_KEY" key in its dictionary of its process information environment.
func myMethod() {
var environment = NSProcessInfo.processInfo().environment
if environment["MY_KEY"] {
I would like to check this in unit test. The problem is that changing the environment dictionary in the unit test does not affect the dictionary in the application.
class MyAppTests: XCTestCase {
func testMe() {
var environment = NSProcessInfo.processInfo().environment
environment["MY_KEY"] = "my value"
myMethod()
}
end
Is it possible to change the application environment dictionary with unit test?
source
share