ios - How to change app's NSProcessInfo environment dictionary from a unit test? -
i have following code in app. behaviour can altered setting "my_key" key in environment dictionary of process information.
func mymethod() { var environment = nsprocessinfo.processinfo().environment if environment["my_key"] { /* /* } }
i test in unit test. problem changing environment dictionary in unit test no affect dictionary in app.
class myapptests: xctestcase { func testme() { var environment = nsprocessinfo.processinfo().environment environment["my_key"] = "my value" mymethod() // app's environment not change } end
is possible change environment dictionary of app unit test?
the environment provided nsprocessinfo read-only. can set environment variable using setenv
c function (works fine swift), this:
setenv("my_key", "my value", 1)
Comments
Post a Comment