|
|
|
|
|
by billmcneale
498 days ago
|
|
Yes, you gain testability. If your global state contains something that runs in prod but should not run in a testing environment (e.g. a database connection), your global variable based code is now untestable. Dependency Injection is popular for a very good reason. |
|
If you have something that should only run in testing, perhaps your test harness should set the global variable appropriately, no?