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

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -