title: How to test code dependent on environment variables using JUnit?
body: <p>I have a piece of Java code which uses an environment variable and the behaviour of the code depends on the value of this variable. I would like to test this code with different values of the environment variable. How can I do this in JUnit?</p>
  
  <p>I've seen <a href="https://stackoverflow.com/questions/318239/how-do-i-set-environment-variables-from-java">some ways to set environment variables in Java</a> in general, but I'm more interested in unit testing aspect of it, especially considering that tests shouldn't interfere with each other.</p>