Testing Environment-Dependent Code in Rust (opens in new tab)
The problem When we have a function that interacts with external resources, testing that code might be difficult because side-effects could impact on other tests. Environment variables are global variables stored in the process state. One change in an env variable changes the process state, so this mutation persists along the process lifetime. In Rust, unit tests are compiled into one binary, which means that all tests run in the same process. That is why we need to be careful when testing co...
Read the original article