title: How do I test code that requires an Environment Variable?
body: <p>I have some code that requires an Environment Variable to run correctly. But when I run my unit tests, it bombs out once it reaches that point unless I specifically export the variable in the terminal. I am using Scala and sbt. My code does something like this:</p>
  
  <pre><code>class something() {
  
    val envVar = sys.env("ENVIRONMENT_VARIABLE")
  
    println(envVar)
  
  }
  </code></pre>
  
  <p>How can I mock this in my unit tests so that whenever sys.env("ENVIRONMENT_VARIABLE") is called, it returns a string or something like that?</p>